home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CDOSDSK5.ZIP / CDOSDSK5.TD0 / XIOS / WINDOWS3.A86 < prev    next >
Encoding:
Text File  |  1989-01-26  |  21.9 KB  |  965 lines

  1. ; WINDOWS3.A86
  2. title 'WINDOW Data and Primitives'
  3. pagesize 60+11
  4. ;****************************************
  5. ;*                    *
  6. ;*    PRIMITIVE CRT ROUTINES        *
  7. ;*    WINDOW DATA            *
  8. ;*    CDOS 6.0 XIOS            *
  9. ;*    DRI OS ENGR, JMB, GMS, PAR    *
  10. ;*                    *
  11. ;****************************************
  12. ; Major mods:
  13. ; 6.x
  14. ; 25 SEP 88 -- extra params to VS_ for background video support      GMS
  15. ; 11 APR 88 -- Data variable moved into PUBDATA.A86          GMS
  16. ;  4 FEB 88 -- VS_CUR_TYPE_HW updated in trans_cur_type          GMS
  17. ; 11 JAN 88 -- new VS_ variable to hold PC equipment word      GMS
  18. ;  7 DEC 87 -- VS_SCREEN_MODE now uses ROS video mode values      GMS
  19. ;  2 DEC 87 -- replaced ega$ with redefined video$          GMS
  20. ; 6.0
  21. ; 18 NOV 87 -- re-enable AST color card support              GMS
  22. ;  2 NOV 87 -- changed graphics error msg              GMS
  23. ; 17 JUL 87 -- converted XIOS to small model              JW
  24. ; 5.2
  25. ; 26 MAY 87 -- changed graphics error message - to suspended    - GMS
  26. ; 13 APR 87 -- added message for serial terminal process abort    - GMS
  27. ; 27 FEB 87 -- VS_ structure increased for EGA blink toggle    - GMS
  28. ; 5.1
  29. ; 27 OCT 86 -- VS_ structure increased for Hercules support     - PAR
  30. ; 15 OCT 86 -- VS_ structure increased for ANSI support        - GMS
  31. ; 15 JUL 86 -- trans_cur_type pop bug
  32. ; 18 APR 86 -- add VS_CUR_TYPE_HW to vs_
  33. ;  3 JAN 85 -- add graphics mode error msg
  34. ; 22 NOV 85 -- add VS_COLORSEL entry
  35. ;  8 NOV 85 -- support AST "Colorgraphplus" in video_out@
  36. ; 12 SEP 85 -- don't sti in video_out@
  37. ; 19 JUL 85 -- support io_devio w/ put_crt_dev@
  38. ; 14 JUN 85 -- update 4.1 ASM86 XIOS to RASM86
  39.  
  40. ; include COPYRITE.TXT
  41.  
  42. nolist
  43. include CDOS.EQU
  44. include XIOS.EQU
  45. include PCHW.EQU
  46. include ROSDATA.EQU
  47. list
  48. ; These were included:
  49. ; include CDOS.EQU
  50. ; include XIOS.EQU
  51. ; include PCHW.EQU
  52. ; include ROSDATA.EQU
  53.  
  54. CGROUP    group    CODE
  55. DGROUP    group    DATA,w3dseg0
  56.  
  57. public    draw_frame_s@,    draw_frame_d@,    draw_frame@
  58. public    put_if_ours@,    copy_full_top@,    put_crt_s@
  59. public    put_mon_c@,    put_crt_c@,    get_crt_c@
  60. public    video_out@,    put_crt_m@,    erase_crt@
  61. public    put_crt_dev@,    trans_cur_type@
  62.  
  63.  
  64. public    scroll_mode$
  65. public    s_lines$,    d_lines$
  66. public    var_cursor$,    var_sync$
  67.  
  68.  
  69. public    table_vs$, first_vs$
  70. public    fatal_gr_msg$,    FATAL_GR_MSG_LENGTH
  71. public    fatal_ser_msg$,    FATAL_SER_MSG_LENGTH
  72. public    mono_params$, MONO_PARAMS_LEN$
  73.  
  74.     cseg
  75. extrn    sysdat$        :word                ; in HEADER.A86
  76. extrn    con_normal@    :near, old_cursor_off@    :near    ; in WINDOWS1.A86
  77. extrn    point_vs@    :near, point_cursor@    :near    ; in WINDOWS2.A86
  78. extrn    xlat_priority@    :near, check_full_top@    :near
  79.  
  80.     dseg
  81. extrn    pfk_tbl0$    :byte, pfk_tbl1$    :byte    ; in CONIN.A86
  82. extrn    pfk_tbl2$    :byte, pfk_tbl3$    :byte
  83. extrn    ast_enhanced$    :word, video$        :byte    ; in WINDOWS1.A86
  84. extrn    ast_flag$:byte
  85. extrn    pc_at$        :byte                ; in FLOPPY.A86
  86. extrn    blank$        :word                ; in PUBDATA.A86
  87. extrn    vc_map_seg$    :word
  88. extrn    mode_reg$    :byte,    top_screen_mode$:byte
  89. extrn    im_here$    :byte,    vc_priority$    :byte
  90. extrn    top_screen$    :byte,    vc_list$    :word
  91. extrn    mono_xlat$     :byte,    color_xlat$    :byte
  92.  
  93. eject
  94.  
  95. ;********************************************************
  96. ;*                            *
  97. ;*        CHARACTER OUT PRIMITIVES        *
  98. ;*                            *
  99. ;********************************************************
  100.  
  101.     cseg
  102.  
  103. draw_frame_s@:
  104. ;------------
  105. ; Draw a single line frame:
  106. ;  save:    dx for double frame
  107.  
  108.     push    dx
  109.     mov    dl,top_screen$            ; old top frame
  110.     call    point_vs@            ; bx -> old vs_
  111.     call    copy_full_top@            ; if full, copy to image
  112.     call    old_cursor_off@            ; for 2 monitor switch
  113.     mov    si,offset s_lines$
  114.     call    draw_frame@            ; single line frame
  115.     pop    dx
  116.     ret
  117.  
  118. draw_frame_d@:
  119. ;------------
  120. ; Draw a double line frame:
  121. ;  entry:    bx -> vs_
  122.  
  123.     mov    si,offset d_lines$
  124. ;    jmps    draw_frame@            ; double line frame
  125.  
  126.  
  127. draw_frame@:
  128. ;-----------
  129. ; Draw frame around the window
  130. ;  entry:    bx -> vs_
  131. ;        si -> line data
  132.  
  133.     mov    dx,VS_TOP_LEFT
  134.     mov    cx,VS_COLS            ; column count
  135.     dec    dh                ; up one row
  136.      js    draw_f1                ; skip if top row
  137.     mov    ax,TOP_CORNERS
  138.     call    hline                ; top line + corners
  139. draw_f1:
  140.     mov    dh,VS_BOTTOM
  141.     inc    dh                ; down on row
  142.     cmp    dh,CRT_ROWS_C            ; never draw the frame
  143.      jae    draw_f2                ;   below line 23
  144.     mov    ax,BOT_CORNERS
  145.     call    hline                ; bottom line + corners
  146. draw_f2:
  147.     mov    dx,VS_TOP_LEFT
  148.     mov    cx,VS_ROWS            ; row count
  149.     dec    dl                ; left one column
  150.      js    draw_f3                ; skip if 1st column
  151.  
  152.     call    vline                ; left line only
  153. draw_f3:
  154.     mov    dl,VS_RIGHT
  155.     inc    dl                ; right one column
  156.     cmp    dl,CRT_COLS
  157.      jz    draw_f4                ; skip if last column
  158.  
  159.     call    vline                ; right line only
  160. draw_f4:
  161.     ret
  162. eject
  163.  
  164. hline:
  165. ;-----
  166. ; Draw a horizontal line with corners:
  167. ;  entry:    dx=row,col  cx=col count  ax=corners
  168.  
  169.     push    es
  170.     push    si
  171.     push    dx
  172.     push    cx
  173.     push    ax                ; save corners
  174.     mov    ax,HORIZ            ; horiz line + attrib
  175.     mov    h_copy,ax            ; save for draw
  176.  
  177.     call    point_cursor@            ; di -> line start
  178.     xchg    ax,si                ; si -> map
  179.     mov    es,vc_map_seg$            ; for owner check
  180.     cmp    dl,0                ; if at left edge
  181.      jz    hline1                ;   skip first corner
  182.  
  183.     pop    ax
  184.     push    ax
  185.     dec    di                ; back up for corner
  186.     dec    di
  187.     dec    si                ; on the map too
  188.     mov    ah,a_copy            ; frame attribute
  189.     call    put_if_ours@            ; to the screen
  190. hline1:
  191.     add    dl,cl                ; get to right column
  192.     dec    dl
  193.     mov    ax,h_copy            ; horiz line + attrib
  194. hline2:
  195.     call    put_if_ours@            ; to the screen
  196.     loop    hline2                ; cx times
  197.  
  198.     pop    ax                ; corners again
  199.     cmp    dl,CRT_COLS-1            ; if at right edge
  200.      jz    hline3                ;   skip last corner
  201.     mov    al,a_copy            ; frame attribute
  202.     xchg    al,ah
  203.     call    put_if_ours@            ; to the screen
  204. hline3:
  205.     pop    cx
  206.     pop    dx
  207.     pop    si
  208.     pop    es
  209.     ret
  210.  
  211. eject
  212.  
  213. vline:
  214. ;-----
  215. ; Draw a vertical line  (no corners):
  216. ;  entry:    dx=row,col  cx=row count
  217.  
  218.     push    es
  219.     push    si
  220.     push    cx
  221.     push    VERT                ; save vert line
  222.     call    point_cursor@            ; di -> line start
  223.     xchg    ax,si                ; si -> map
  224.     mov    es,vc_map_seg$            ; for owner check
  225.     pop    ax                ; vert line + attrib
  226. vline1:
  227.     call    put_if_ours@            ; to the screen
  228.     add    di,2*(CRT_COLS-1)
  229.     add    si,CRT_COLS-1
  230.     loop    vline1                ; num of rows times
  231.     pop    cx
  232.     pop    si
  233.     pop    es
  234.     ret
  235.  
  236.  
  237. put_if_ours@:
  238. ;-----------
  239. ; Put a frame char to screen if we own it:
  240. ;  entry:    ax = char + attrib
  241. ;        es:si -> vc_map
  242. ;        di -> crt
  243.  
  244.     push    ax                ; save char
  245.     mov    al,es:[si]            ; get map code
  246.     inc    si                ; to next char
  247.     call    xlat_priority@            ; who owns it?
  248.     cmp    al,VS_NUMBER            ; if not us
  249.     pop    ax                ;   then skip
  250.      jnz    put_if1
  251.     jmp    put_crt_c@            ; print one char
  252. put_if1:
  253.     inc    di                ; bump destination
  254.     inc    di
  255.     ret
  256. eject
  257.  
  258. erase_crt@:
  259. ;---------
  260. ; Clear the unowned portions of the screen:
  261. ;  entry:    dh = vc bit mask
  262. ;        dl = VS_MODE (08 to sync)
  263. ;        bx = crt_segment
  264.  
  265.     push    es
  266.     sub    si,si                ; start at top left
  267.     sub    di,di
  268.     mov    es,vc_map_seg$
  269.     mov    cx,CRT_ROWS_C * CRT_COLS
  270.     mov    ax,blank$            ; space + attrib
  271. erase_crt1:
  272.     test    es:byte ptr [si],dh
  273.      jnz    erase_crt2            ; skip if owned
  274.     call    put_mon_c@            ; straight to monitor
  275.     jmps    erase_crt3            ; di taken care of
  276.  
  277. erase_crt2:
  278.     inc    di                ; next crt char
  279.     inc    di
  280. erase_crt3:
  281.     inc    si                ; next map char
  282.     loop    erase_crt1
  283.  
  284.     pop    es        ; restore extra seg
  285.     ret
  286. eject
  287.  
  288. copy_full_top@:
  289. ;-------------
  290. ; Copy crt back to vc image when full screen on top:
  291. ;  entry:    bx -> vs_
  292.  
  293.     call    check_full_top@    ; if not full top screen
  294.      jnz    copy_f_done    ;   then skip
  295.  
  296. ; Top screen is full, save it:
  297.     push    cx
  298.     push    dx
  299.     push    ds ! push es
  300.     sub    si,si                ; top left
  301.     sub    di,di                ;   of both
  302.     mov    al,CRT_COLS
  303.     mul    VS_CRT_ROWS            ; ax = our crt size
  304.     mov    cx,ax
  305.     mov    es,VS_VC_SEG            ; image is destination
  306.     mov    ds,VS_CRT_SEG
  307.     mov    ah,IN_SYNC            ; sync for reading
  308.     call    put_crt_m@            ; general mover
  309.     pop    es ! pop ds
  310.     pop    dx
  311.     pop    cx
  312.     or    VS_MODE,MATCH_BIT
  313. copy_f_done:
  314.     ret
  315. eject
  316.  
  317. put_crt_s@:
  318. ;---------
  319. ; Store characters to crt  (like a rep stosw):
  320. ;  entry:    di -> cursor location
  321. ;        ax = attribute, character
  322. ;        bx -> vs_
  323. ;        cx = char count
  324.  
  325.     push bx ! push dx ! push es
  326.     mov    es,VS_CRT_SEG            ; get our segment
  327.  
  328.     test    VS_MODE,SYNC_BIT
  329.      jz    put_s_all            ; skip if not syncing
  330.     cmp    cx,STOS_BURST            ; if less than one burst
  331.      jbe    put_s_slow            ;   then sneak it in
  332.     cmp    scroll_mode$,0            ; if we're default scroll mode
  333.      jz    put_s_fast            ;   then blast it
  334.     cmp    scroll_mode$,2            ; if we're wide open
  335.      jz    put_s_all            ;   then just ship it
  336.  
  337.  
  338. put_s_slow:
  339. ;----------
  340. ; Slow non-flickering erase:
  341.  
  342.     mov    dx,COLOR_PORT+6
  343. put_s_top:
  344.     mov    bx,ax                ; save char in bx
  345. put_s_wait:
  346.     sti                    ; allow an interrupt
  347.     nop
  348.     cli                    ;; hold the ints
  349.     in    al,dx
  350.     test    al,VRT                ;; if vertical retrace
  351.      jnz    put_s_burst            ;;   then store a burst
  352.     test    al,HRT                ;; if horiz retrace
  353.      jnz    put_s_wait            ;;   then stay here
  354. put_s_no_hrt:
  355.     in    al,dx
  356.     test    al,HRT
  357.      jz    put_s_no_hrt            ; wait for fresh HRT
  358.     xchg    ax,bx                ; char back to ax
  359.     stosw                    ; put it out
  360.     loop    put_s_top            ; more if you've got 'em
  361.     jmps    put_s_done            ; done if not
  362.  
  363. put_s_fast:
  364. ;----------
  365. ; Fast flickering erase:
  366.  
  367.     call    disable_video
  368.     rep    stosw                ; get it over with
  369.     call    enable_video
  370.     jmps    put_s_done
  371.  
  372.  
  373. put_s_burst:
  374. ; Vertical retrace, put a burst:
  375. ; Now we're sure to have less than STOS_BURST.
  376.  
  377.     xchg    ax,bx                ; char back to ax
  378.  
  379. put_s_all:
  380.     rep    stosw                ; store them all
  381.  
  382. put_s_done:
  383. ; Finished with the store:
  384.     sti                    ; allow interrupts
  385.     pop es ! pop dx ! pop bx
  386.     ret
  387. eject
  388.  
  389. put_crt_m@:
  390. ;---------
  391. ; Generalized move to/from crt:
  392. ;  entry:    ds:si -> source
  393. ;        es:di -> destination
  394. ;        cx = char count
  395. ;        ah = sync flag
  396.  
  397.     push    bx
  398.     push    dx
  399.     push    bp
  400.  
  401.     push    ds
  402.     mov    ds,sysdat$
  403.     test    VS_MODE,SYNC_BIT
  404.     pop    ds
  405.      jz    put_m_all            ; skip if not syncing
  406.     test    ah,ah                ; if no sync bits
  407.      jz    put_m_all            ;   then just move
  408.  
  409.     cmp    cx,MOVS_BURST            ; if less than one burst
  410.      jbe    put_m_slow            ;   then sneak it in
  411.     push    ds
  412.     mov    ds,sysdat$
  413.     mov    al,scroll_mode$
  414.     pop    ds
  415.     cmp    al,0                ; use al for speed
  416.      jz    put_m_fast            ; blast it if default
  417.     cmp    al,2                ; if we're wide open
  418.      jz    put_m_all            ;   then just ship it
  419. ;    jmps    put_m_slow
  420.  
  421. put_m_slow:
  422. ; Slow non-flickering scroll:
  423.     mov    dx,COLOR_PORT+6
  424.     mov    bh,ah                ; sync bits live here
  425. put_m_top:
  426.     test    bh,IN_SYNC            ; do we wait on input?
  427.      jz    put_m2                ;   if not, skip
  428. put_m0:
  429.     sti                    ; allow an interrupt
  430.     nop
  431.     cli                    ;; hold the ints
  432.     in    al,dx
  433.     test    al,VRT                ;; if vertical retrace
  434.      jnz    put_m_burst            ;;   then move a burst
  435.     in    al,dx                ;; get a fresh one
  436.     test    al,HRT                ;; if no horiz retrace
  437.      jnz    put_m0                ;;   then stay here
  438. put_m1:
  439.     in    al,dx
  440.     test    al,HRT
  441.      jz    put_m1                ; wait for fresh HRT
  442. put_m2:
  443.     mov    ax,[si]                ; get crt character, keep ptr
  444.     test    bh,OUT_SYNC            ; do we wait on ouput?
  445.      jz    put_m5                ;   if not, skip
  446.     xchg    ax,bp                ; save char in bp
  447. put_m3:
  448.     sti                    ; allow an interrupt
  449.     nop
  450.     cli                    ;; hold the ints
  451.     in    al,dx
  452.     test    al,VRT                ;; if vertical retrace
  453.      jnz    put_m_burst            ;;   then move a burst
  454.     test    al,HRT                ;; if no horiz retrace
  455.      jnz    put_m3                ;;   then stay here
  456. put_m4:
  457.     in    al,dx
  458.     test    al,HRT
  459.      jz    put_m4                ; wait for fresh HRT
  460.     xchg    ax,bp                ; char back to ax
  461. put_m5:
  462.     stosw                    ; put it out
  463.     lods    cs:ax                ; incs or decs si leaving screen alone
  464.     loop    put_m_top            ; more if you've got 'em
  465.     jmps    put_m_done            ; done if not
  466.  
  467. put_m_burst:
  468. ; Vertical retrace, put a burst:
  469.     mov    ax,MOVS_BURST            ;; move count
  470.     cmp    cx,ax                ;; if count is too big
  471.      jbe    put_m_all            ;;   then do a burst
  472.                         ;;   at a time
  473.     sub    cx,ax                ;; first correct the count
  474.     xchg    ax,cx                ;; cx = burst count
  475.     rep    movsw                ;; move a burst
  476.     xchg    ax,cx                ;; corrected count to cx
  477.     jmps    put_m_top            ;; go back for more
  478.  
  479. put_m_fast:
  480. ; Fast flickering scroll:
  481.     call    disable_video
  482.     rep    movsw                ; get it over with
  483.     call    enable_video
  484.     jmps    put_m_done
  485.  
  486. put_m_all:
  487. ; If EGA and AT, move by bytes...the card is not fast enough for word moves.
  488.     push    ds
  489.     mov    ds,sysdat$
  490.     test    video$,EGA+VGA
  491.      jz    not_ega
  492.     test    pc_at$,1
  493.      jz    not_at
  494.     pop    ds
  495.  
  496.     shl    cx,1                ; 2 bytes per word
  497.     rep    movsb                ; move 8 bits at a time
  498.     jmps    put_m_done
  499.  
  500. not_ega:
  501. not_at:    
  502.     pop    ds
  503.     rep    movsw                ; move them all
  504.  
  505. put_m_done:
  506. ; Finished with the move:
  507.     sti                    ; allow interrupts
  508.     pop    bp
  509.     pop    dx
  510.     pop    bx
  511.     ret
  512.  
  513.  
  514.  
  515. enable_video:
  516. ;------------
  517. ; Enable the video beam:
  518.     push    ax
  519.     push    ds
  520.     mov    ds,sysdat$
  521.     mov    al,mode_reg$            ; bit on
  522.     pop    ds
  523.     jmps    shared_video
  524.  
  525. disable_video:
  526. ;-------------
  527. ; Disable the video beam:
  528.     push    ax
  529.     mov    ah,21h                ; bit off
  530.     mov    dx,COLOR_PORT+6
  531. disable_video_loop:
  532.     in    al,dx
  533.     test    al,VRT                ; wait for vertical
  534.       jz    disable_video_loop
  535.     mov    al,ah                ; recover value
  536. shared_video:
  537.     mov    dx,COLOR_PORT+4
  538.     out    dx,al                ; and blast it
  539.     pop    ax
  540.     ret
  541.  
  542.  
  543. put_mon_c@:
  544. ;---------
  545.     push    es
  546.     push    dx
  547.     push    bx
  548.     mov    es,bx                ; set crt segment
  549.     jmps    put_crt_c0            ; sneak in
  550. eject
  551.  
  552. put_crt_c@:
  553. ;---------
  554. ; Store one character to crt  (like a stosw):
  555. ;   entry:    di -> cursor location
  556. ;        ax = attribute, character
  557.  
  558.     push    es
  559.     push    dx
  560.     push    bx
  561.  
  562.     mov    es,VS_CRT_SEG            ; mono or color
  563.     mov    dl,VS_MODE
  564. put_crt_c0:
  565.     test    dl,SYNC_BIT
  566.      jnz    put_c0                ; if sync, skip
  567.     stosw                    ; just ship it
  568.     jmps    put_c_done
  569. put_c0:
  570.     xchg    ax,bx                ; save char in bx
  571.  
  572.     mov    dx,COLOR_PORT+6            ; crt status
  573. put_c1:
  574.     sti                    ; allow an interrupt
  575.     nop
  576.     cli                    ;; hold the ints
  577.     in    al,dx
  578.     test    al,VRT                ;; if vert retrace
  579.      jnz    put_c3                ;;   just do it
  580.     in    al,dx                ;; get a fresh one
  581.     test    al,HRT                ;; if horiz retrace on
  582.      jnz    put_c1                ;;   wait for it to go away
  583. put_c2:
  584.     in    al,dx
  585.     test    al,HRT                ;; wait for fresh horiz rt
  586.      jz    put_c2
  587. put_c3:
  588.     xchg    ax,bx        ;; char back to ax
  589.     stosw            ;; the fastest
  590.     sti
  591. put_c_done:
  592.     pop    bx
  593.     pop    dx
  594.     pop    es
  595.     ret
  596. eject
  597.  
  598. get_crt_c@:
  599. ; Get one character from crt  (like a lodsw):
  600. ;  entry:    si -> cursor location
  601. ;  exit:    ax = attribute, character
  602.  
  603.     push    ds
  604.     push    dx
  605.     mov    dl,VS_MODE
  606.     mov    ds,VS_CRT_SEG            ; mono or color
  607. get_crt_c0:
  608.     test    dl,SYNC_BIT
  609.      jz    get_c3                ; if no sync, skip
  610.     mov    dx,COLOR_PORT+6            ; crt status
  611. get_c1:
  612.     sti                    ; allow an interrupt
  613.     nop
  614.     cli                    ;; hold the ints
  615.     in    al,dx
  616.     test    al,VRT                ;; if vert retrace
  617.      jnz    get_c3                ;;   just do it
  618.     in    al,dx                ;; get a fresh one
  619.     test    al,HRT                ;; if horiz retrace on
  620.      jnz    get_c1                ;;   wait for it to go away
  621. get_c2:
  622.     in    al,dx
  623.     test    al,HRT                ;; wait for fresh horiz rt
  624.      jz    get_c2
  625. get_c3:
  626.     lodsw                    ;; grab it
  627.     sti                    ;  and get out
  628.     pop    dx
  629.     pop    ds
  630.     ret
  631. eject
  632.  
  633. put_crt_dev@:
  634. ;------------
  635. ; Write a string to crt (padding w/ current attribute)
  636. ; Entry:    bx = vs_ structure
  637. ;        bp = dev_ parameter for io_devio
  638. ;        di = cursor location (word ptr)
  639. ;        ah = current attribute
  640. ;        cx = character count
  641.  
  642.     push es ! push si ! push di ! push ds ! push cx
  643.     mov    es,VS_VC_SEG            ; point to virtual buffer
  644.     lds    si,DEV_BUF_BP            ; get string address
  645.     shr    cx,1                ; div. char. cnt. by 2
  646.     jcxz    put_cdev_15            ; skip if no pairs
  647. put_cdev_10:
  648.     lodsb ! stosw                ; get byte, store byte+attr
  649.     lodsb ! stosw                ; two per loop for speed
  650.     loop    put_cdev_10            ; repeat for all pairs
  651. put_cdev_15:
  652.      jnc    put_cdev_20            ; skip if no odd one left
  653.     lodsb ! stosw                ; else do the last one
  654. put_cdev_20:
  655.     pop cx ! pop ds ! pop di        ; restore SYSDAT and cursor
  656.     mov    es,VS_CRT_SEG            ; move into phys. screen RAM
  657.     push di ! push ds            ; keep SYSDAT safe
  658.     mov    si,di                ; source and dest. offset match
  659.     test    VS_MODE,SYNC_BIT        ; need to sync?
  660.     mov    ds,VS_VC_SEG            ; from virtual plane
  661.      jnz    put_cdev_30            ; jmp if yes
  662.     rep    movsw                ; else do it
  663.     jmps    put_cdev_40            ; finished
  664. put_cdev_30:
  665.     mov    ah,OUT_SYNC            ; sync on writes
  666.     call    put_crt_m@            ; do optimized move
  667. put_cdev_40:
  668.     pop ds ! pop di ! pop si ! pop es
  669.     ret
  670. eject
  671.  
  672. video_out@:
  673. ;---------
  674. ; Video controller port output:
  675. ;  entry:    al = first data register number
  676. ;        bx -> vs_
  677. ;        cx = two data bytes
  678.  
  679.     push    dx
  680.     mov    dx,MONO_PORT            ; assume monochrome
  681.     cmp    VS_CRT_SEG,MONO_SEG
  682.      jz    video_out1            ; skip if true
  683.     mov    dx,COLOR_PORT            ; color port if false
  684. video_out1:
  685.     pushf                    ; save interrupt flag
  686.     cli                    ; critical section
  687.     out    dx,al                ;;   set port number
  688.     inc    dx                ;;   data register
  689.     xchg    al,ch                ;;  al = first data
  690.     out    dx,al                ;;
  691.     dec    dx                ;;  back to set port
  692.     xchg    al,ch                ;;
  693.     inc    ax                ;;   next port
  694.     out    dx,al                ;;
  695.     inc    dx                ;;
  696.     mov    al,cl                ;;  second data
  697.     out    dx,al                ;;
  698.  
  699. ; Support the AST "Colorgraphplus" card:
  700. ; (Most every hit of the CRTC registers seems to require a re-hit here:) 
  701.  
  702. if not QXM
  703.     test    ast_flag$,0ffh            ; make sure it is possibly AST
  704.     jz    not_ast
  705.  
  706.     mov    dx,AST_ENHANCED_PORT        ;;
  707.     mov    al,byte ptr ast_enhanced$    ;; toggled by keyboard
  708.     out    dx,al                ;;
  709. not_ast:
  710. endif
  711.     popff    iret_op@            ;; section done
  712.     pop    dx
  713.     ret
  714. eject
  715.  
  716. trans_cur_type@:
  717. ;----------------
  718. ; Entry:    CX = CGA-compatible cursor type (ala VS_CUR_TYPE)
  719. ;        BX = VS_
  720. ; Exit:        CX = EGA equivalent as function of ECD presence
  721. ;        Uses AX
  722.  
  723.     test    video$,EGA+VGA
  724.     jz    trans_back1
  725.  
  726. ; Here to trans cursor type
  727.     push    dx
  728.     push    di
  729.     mov    ah,ch
  730.     and     ah,60h
  731.     cmp    ah,20h                ; no curs?
  732.      jne    ega_on
  733.     mov    cx,01E00h            ; curs off for ega
  734.     jmps    trans_back
  735. ega_on:
  736.     cmp    VS_SCREEN_MODE,04
  737.      jb    test_ecd
  738.     cmp    VS_SCREEN_MODE,07
  739.      jne    no_ecd                ; jump if graphics mode
  740. test_ecd:
  741.     test    video$,ECD            ; ecd attached?
  742.      jz    no_ecd
  743.  
  744.     cmp    ch,4
  745.      jbe    ye
  746.     add    ch,5     
  747. ye:
  748.     cmp    cl,4
  749.      jbe    ye1
  750.     add    cl,5
  751. ye1:
  752. no_ecd:
  753.     cmp    ch,0
  754.      jnz    not_0
  755.     inc    cl
  756.     jmps    ne_1
  757. not_0:
  758.     inc    cl
  759.     mov    dx,ds            ; save seg
  760.      mov    di,PC_SEGMENT
  761.      mov    ds,di
  762.      cmp    cl,.85h
  763.     mov    ds,dx
  764.      jb    ne_1
  765.     sub    cl,cl
  766. ne_1:
  767.     push    cx
  768.     sub    cl,ch
  769.     cmp    cl,10h
  770.     pop    cx
  771.      jne    ye2
  772.     inc    cl
  773. ye2:
  774. trans_back:
  775.     pop    di
  776.     pop    dx
  777. trans_back1:
  778.     mov    VS_CUR_TYPE_HW,cx    ; save hardware cursor
  779.     ret
  780. eject
  781.  
  782. ;********************************************************
  783. ;*                            *
  784. ;*        CONSOLE OUT VARIABLES            *
  785. ;*                            *
  786. ;********************************************************
  787.  
  788. w3dseg0        dseg    word
  789.  
  790. c_copy        rb    1            ; character
  791. a_copy        rb    1            ; attribute
  792. h_copy        equ    word ptr c_copy
  793.  
  794. scroll_mode$    db    0            ; 0 => fast flicker, 1 => slow snake
  795.                         ; 2 => wide open
  796. ; Single / double line frame drawing data:
  797.  
  798. HORIZ        equ    word ptr 0[si]
  799. VERT        equ    word ptr 2[si]
  800. TOP_CORNERS    equ    word ptr 4[si]
  801. BOT_CORNERS    equ    word ptr 6[si]
  802.  
  803. s_lines$    dw    07C4h,07B3h
  804.         dw    0BFDAh,0D9C0h
  805.  
  806. d_lines$    dw    0FCDh,0FBAh
  807.         dw    0BBC9h,0BCC8h
  808.  
  809. ; Variable video params for the COMPAQ:
  810.  
  811. var_cursor$    dw    COLOR_CURSOR            ; hi or low res
  812. var_sync$    db    SYNC_BIT            ; to sync or not
  813.         db    0DBh                ; pad
  814.  
  815.  
  816. CRT_FULL    equ    100h * (CRT_ROWS_C - 1) + (CRT_COLS - 1)
  817.  
  818. ; Virtual console data tables:
  819.  
  820. table_vs$    dw    first_vs$,second_vs,third_vs,fourth_vs
  821.  
  822. first_vs$    dw    0,0,CRT_FULL
  823.         dw    0,CRT_FULL,CRT_FULL
  824.         dw    1850H,0
  825.         dw    CRT_ROWS_C,CRT_COLS,0
  826.         dw    0,0,vc_list$
  827.         db    07h,INIT_MODE,1,CRT_COLS,0,1
  828.         dw    0,con_normal@,0
  829.         db    CRT_ROWS_C,0
  830.         dw    0,0
  831.         dw    pfk_tbl0$,0,0FF00h
  832.         dw    0,0,0,0,0
  833.         db    1,0
  834.         dw    0
  835.         db    30h                ; color sel 80 alpha
  836.         dw    0                ; scratch
  837.         db    0                ; graphics wait flag
  838.         dw    0                ; cur_type_hw
  839.         db    0                ; hercules mode
  840.         db    01                ; default blink toggle
  841.         db     0,1,2,3,4,5,14h,7,38h,39h    ; default pallette 
  842.         db    3ah,3bh,3ch,3dh,3eh,3fh,0    ; settings + overscan
  843.         dw    00                ; PC equipment word
  844.         dw    0000h                ; ansi options count
  845.         rb    VS_ANSI_SIZE            ; ansi input buffer
  846. ;if BACKG
  847.         db    0                ; virtual port 3?4h
  848.         rb    0                ; virtual port 3?5h
  849.         db    71h,50h,5ah,0ah,1fh,6,19h,1ch,2,7,6,7
  850.         db    0,0,0,0,0,0,0,0
  851.         db    0                ; virtual port 3?Ah
  852. ;endif
  853.  
  854. second_vs    dw    0,0,CRT_FULL
  855.         dw    0,CRT_FULL,CRT_FULL
  856.         dw    1850H,0
  857.         dw    CRT_ROWS_C,CRT_COLS,0
  858.         dw    0,0,vc_list$
  859.         db    07h,INIT_MODE,1,CRT_COLS,1,2
  860.         dw    0,con_normal@,0
  861.         db    CRT_ROWS_C,0
  862.         dw    0,0
  863.         dw    pfk_tbl1$,0,0FF00h
  864.         dw    0,0,0,0,0
  865.         db    1,0
  866.         dw    0
  867.         db    30h                ; color sel 80 alpha
  868.         dw    0                ; scratch
  869.         db    0                ; graphics wait flag
  870.         dw    0                ; cur_type_hw
  871.         db    0                ; hercules mode
  872.         db    01                ; default blink toggle
  873.         db     0,1,2,3,4,5,14h,7,38h,39h    ; default pallette 
  874.         db    3ah,3bh,3ch,3dh,3eh,3fh,0    ; settings + overscan
  875.         dw    00                ; PC equipment word
  876.         dw    0000h                ; ansi options count
  877.         rb    VS_ANSI_SIZE            ; ansi input buffer
  878. ;if BACKG
  879.         db    0                ; virtual port 3?4h
  880.         rb    0                ; virtual port 3?5h
  881.         db    71h,50h,5ah,0ah,1fh,6,19h,1ch,2,7,6,7
  882.         db    0,0,0,0,0,0,0,0
  883.         db    0                ; virtual port 3?Ah
  884. ;endif
  885.  
  886. third_vs    dw    0,0,CRT_FULL
  887.         dw    0,CRT_FULL,CRT_FULL
  888.         dw    1850H,0
  889.         dw    CRT_ROWS_C,CRT_COLS,0
  890.         dw    0,0,vc_list$
  891.         db    07h,INIT_MODE,1,CRT_COLS,2,4
  892.         dw    0,con_normal@,0
  893.         db    CRT_ROWS_C,0
  894.         dw    0,0
  895.         dw    pfk_tbl2$,0,0FF00h
  896.         dw    0,0,0,0,0
  897.         db    1,0
  898.         dw    0
  899.         db    30h                ; color sel 80 alpha
  900.         dw    0                ; scratch
  901.         db    0                ; graphics wait flag
  902.         dw    0                ; cur_type_hw
  903.         db    0                ; hercules mode
  904.         db    01                ; default blink toggle
  905.         db     0,1,2,3,4,5,14h,7,38h,39h    ; default pallette 
  906.         db    3ah,3bh,3ch,3dh,3eh,3fh,0    ; settings + overscan
  907.         dw    00                ; PC equipment word
  908.         dw    0000h                ; ansi options count
  909.         rb    VS_ANSI_SIZE            ; ansi input buffer
  910. ;if BACKG
  911.         db    0                ; virtual port 3?4h
  912.         rb    0                ; virtual port 3?5h
  913.         db    71h,50h,5ah,0ah,1fh,6,19h,1ch,2,7,6,7
  914.         db    0,0,0,0,0,0,0,0
  915.         db    0                ; virtual port 3?Ah
  916. ;endif
  917.  
  918. fourth_vs    dw    0,0,CRT_FULL
  919.         dw    0,CRT_FULL,CRT_FULL
  920.         dw    1850H,0
  921.         dw    CRT_ROWS_C,CRT_COLS,0
  922.         dw    0,0,vc_list$
  923.         db    07h,INIT_MODE,1,CRT_COLS,3,8
  924.         dw    0,con_normal@,0
  925.         db    CRT_ROWS_C,0
  926.         dw    0,0
  927.         dw    pfk_tbl3$,0,0FF00h
  928.         dw    0,0,0,0,0
  929.         db    1,0
  930.         dw    0
  931.         db    30h                ; color sel 80 alpha
  932.         dw    0                ; scratch
  933.         db    0                ; graphics wait flag
  934.         dw    0                ; cur_type_hw
  935.         db    0                ; hercules mode
  936.         db    01                ; default blink toggle
  937.         db     0,1,2,3,4,5,14h,7,38h,39h    ; default pallette 
  938.         db    3ah,3bh,3ch,3dh,3eh,3fh,0    ; settings + overscan
  939.         dw    00                ; PC equipment word
  940.         dw    0000h                ; ansi options count
  941.         rb    VS_ANSI_SIZE            ; ansi input buffer
  942. ;if BACKG
  943.         db    0                ; virtual port 3?4h
  944.         rb    0                ; virtual port 3?5h
  945.         db    71h,50h,5ah,0ah,1fh,6,19h,1ch,2,7,6,7
  946.         db    0,0,0,0,0,0,0,0
  947.         db    0                ; virtual port 3?Ah
  948. ;endif
  949.  
  950. mono_params$    db    61h,80,52h,0fh,25,6,25,25,2,0dh,0bh,0ch
  951. MONO_PARAMS_LEN$    equ    offset $ - offset mono_params$
  952.  
  953. ; We only have the space to save alpha consoles.
  954. fatal_gr_msg$    db    0dh,0ah,'Concurrent Error:  This program suspended'
  955.         db    ' while other program in graphics.'
  956. FATAL_GR_MSG_LENGTH equ offset $ - offset fatal_gr_msg$
  957.  
  958. fatal_ser_msg$    db    0dh,0ah,'Concurrent Error:  This program '
  959.         db    'can not run on a serial console.'
  960. FATAL_SER_MSG_LENGTH equ offset $ - offset fatal_ser_msg$
  961.  
  962. end
  963.  
  964. ; END OF WINDOWS3.A86 
  965.