home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / IBMLIB / SC_DRIVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-09-25  |  19.8 KB  |  824 lines

  1. ;
  2. ;  sc_drive.asm
  3. ;
  4. ;  Purpose: Screen handling primitives.
  5. ;
  6. ;  Blackstar C Function Libarary
  7. ;  (c) Copyright 1985,1989 Sterling Castle Software
  8. ;
  9.  
  10.     include model
  11.     include blackstr.mac
  12.  
  13.  
  14.     ;-------------------------------------
  15.     ;       equates for bios interface.
  16.     ;-------------------------------------
  17.     ;
  18.     ;       the interrupt and codes for the screen interface interrupt.
  19.  
  20.     video           equ     10h     ;interrupt for dealing with screen
  21.  
  22.     mode            equ     0       ;code for setting new screen mode
  23.     curtype         equ     1       ;code for setting new cursor type
  24.     setcur          equ     2       ;code for addressing cursor
  25.     readcur         equ     3       ;code for reading cursor location
  26.     pageud          equ     5       ;code for changing text page
  27.     scrollup        equ     6       ;code to scroll screen up
  28.     scrolldn        equ     7       ;code to scroll screen down
  29.     readch          equ     8       ;code to read a character from screen
  30.     writeca         equ     9       ;code to write char and attributes
  31.     writech         equ     10      ;code to write character only
  32.     setpal          equ     11      ;code to set new setpal or border
  33.     wdot            equ     12      ;code to write a dot
  34.     rdot            equ     13      ;code to read a dot
  35.     wtty            equ     14      ;code to write as if teletype
  36.     state           equ     15      ;code to find current screen status
  37.  
  38.     bwstat          equ     03bah   ;B/W status port
  39.     clstat          equ     03dah   ;Color status port
  40.     crt_cols        equ     80
  41.     crt_rows        equ     25
  42.  
  43.     NOADP           equ     0ffh    ;no adapter present
  44.     MONADP          equ     01      ;monochrome adapter
  45.     CGAADP          equ     02      ;cga adapter
  46.     EGAADP          equ     04      ;ega adapter
  47.  
  48.  
  49.     dseg    'DATA'
  50.  
  51.     ;-------------------------------------------
  52.     ;       external variables used from C program
  53.     ;----------------------------------------------
  54.  
  55.     public _sc_attr_,_sc_cols_,_sc_rows_,_sc_adpt_
  56.     public _sc_mem_, _sc_mode_,_sc_page_,_sc_col_,_sc_row_
  57.     public _sc_colr_,_sc_adp_, _sc_ega_, _sc_mem_
  58.     public _colst_,  _colen_,  _rowst_,  _rowen_
  59.  
  60.     ifdef   asm_386
  61.     alias   colst_,dword
  62.         _colst_         dd      0       ;starting column
  63.     alias   colen_,dword
  64.         _colen_         dd      0       ;ending column
  65.     alias   rowst_,dword
  66.         _rowst_         dd      0       ;starting row
  67.     alias   rowen_,dword
  68.         _rowen_         dd      0       ;ending row
  69.  
  70.     alias   sc_cols_,dword
  71.         _sc_cols_       dd      0       ;# columns
  72.     alias   sc_col_,dword
  73.         _sc_col_        dd      0       ;current column
  74.     alias   sc_attr_,byte
  75.         _sc_attr_       db      7       ;current attributes for screen
  76.     alias   sc_adp_,byte
  77.         _sc_adp_        db      255     ;monitor type 0-BW,1-CGA,2-EGA
  78.     alias   sc_ega_,byte
  79.         _sc_ega_        db      0       ;EGA switch setting
  80.     alias   sc_colr_,byte
  81.         _sc_colr_       db      0       ;EGA color bit
  82.     alias   sc_mem_,byte
  83.         _sc_mem_        db      0       ;EGA memory size in k's
  84.     alias   sc_row_,dword
  85.         _sc_row_        dd      0       ;current row
  86.     alias   sc_rows_,dword
  87.         _sc_rows_       dd      0       ;# rows
  88.     alias   sc_page_,dword
  89.         _sc_page_       dd      0       ;current page
  90.     alias   sc_mode_,dword
  91.         _sc_mode_       dd      0       ;current mode
  92.     else
  93.     alias   colst_,word
  94.         _colst_         dw      0       ;starting column
  95.     alias   colen_,word
  96.         _colen_         dw      0       ;ending column
  97.     alias   rowst_,word
  98.         _rowst_         dw      0       ;starting row
  99.     alias   rowen_,word
  100.         _rowen_         dw      0       ;ending row
  101.  
  102.     alias   sc_cols_,word
  103.         _sc_cols_       dw      0       ;# columns
  104.     alias   sc_col_,word
  105.         _sc_col_        dw      0       ;current column
  106.     alias   sc_attr_,byte
  107.         _sc_attr_       db      7       ;current attributes for screen
  108.     alias   sc_adp_,byte
  109.         _sc_adp_        db      255     ;monitor type 0-BW,1-CGA,2-EGA
  110.     alias   sc_ega_,byte
  111.         _sc_ega_        db      0       ;EGA switch setting
  112.     alias   sc_colr_,byte
  113.         _sc_colr_       db      0       ;EGA color bit
  114.     alias   sc_mem_,byte
  115.         _sc_mem_        db      0       ;EGA memory size in k's
  116.     alias   sc_row_,word
  117.         _sc_row_        dw      0       ;current row
  118.     alias   sc_rows_,word
  119.         _sc_rows_       dw      0       ;# rows
  120.     alias   sc_page_,word
  121.         _sc_page_       dw      0       ;current page
  122.     alias   sc_mode_,word
  123.         _sc_mode_       dw      0       ;current mode
  124.     endif
  125.  
  126.     enddseg
  127.  
  128.  
  129.     cseg    sc_gmod_
  130.  
  131. ;-----------------------
  132. ;       sc_gmod_                get the current screen mode
  133. ;-----------------------
  134. ;                               Usage: mode = sc_gmod_();
  135. ;
  136. ;                               int sc_gmod_(void);
  137.  
  138.     public sc_gmod_
  139.  
  140. sc_gmod_ proc
  141.     prolog
  142.  
  143.     ; First, determine the type of adapter present if it has not
  144.     ; already been determined. (MONO,CGA, or EGA)
  145.  
  146.     ifdef   Large_data
  147.     mov     ax,seg dgroup
  148.     mov     ds,ax
  149.     endif
  150.  
  151.     mov     al,sc_adp_      ;get crt adapter type
  152.     cmp     al,NOADP        ;already determined?
  153.     jne     getstate        ;if so, just get current values
  154.  
  155.     mov     ax,1200h        ;EGA alternate select
  156.     mov     bl,10h          ;put in bogus values for color
  157.     mov     bh,0ffh         ; and memory bytes
  158.     int     10h             ;do BIOS call for alternate
  159.     mov     sc_colr_,bh     ;save EGA color bit
  160.     mov     sc_ega_,cl      ;save EGA switch
  161.     mov     sc_mem_,bl      ;save screen memory size
  162.  
  163.     cmp     bh,1            ;0 - color, 1 - mono
  164.     je      monotest
  165.  
  166.     cmp     bl,03h
  167.     jg      monotest
  168.  
  169.     mov     al,EGAADP       ;ega adapter is present
  170.     mov     sc_adp_,al
  171.     jmp     getstate
  172.  
  173. monotest:
  174.     mov     edx,03b4h       ;crt test for mono adapter
  175.     push    edx
  176.  
  177.     ifdef   Large_code
  178.     push    cs
  179.     endif
  180.  
  181.     call    _sc_adpt_
  182.     add     esp,Word_size   ;adjust stack
  183.     mov     sc_adp_,MONADP  ;indicate monochrome
  184.     mov     sc_mem_,16      ;16k
  185.     cmp     eax,1
  186.     je      getstate
  187.  
  188.     mov     edx,03d4h       ;CGA adapter?
  189.     push    edx
  190.  
  191.     ifdef   Large_code
  192.     push    cs
  193.     endif
  194.  
  195.     call    _sc_adpt_
  196.     add     esp,Word_size           ;adjust stack
  197.     mov     sc_adp_,CGAADP  ;it's a cga
  198.     cmp     al,0
  199.     mov     sc_mem_,16      ;16k
  200.     jne     getstate        ;it's a CGA
  201.  
  202.     mov     sc_adp_,NOADP   ;no adapter
  203.  
  204.     ; Now, get the adapter settings.
  205.  
  206. getstate:
  207.     mov     ah,state        ;command for bdos
  208.     int     video           ;do bios interrupt
  209.     mov     cl,bh           ;page to ecx
  210.     mov     ch,0
  211.     mov     bl,ah           ;columns to ebx
  212.     mov     bh,0
  213.     mov     ah,0            ;mode to eax
  214.     mov     _sc_cols_,ebx   ;save columns per line
  215.     mov     _sc_mode_,eax   ;and mode
  216.     mov     _sc_page_,ecx   ;and page
  217.     mov     _sc_rows_,crt_rows;
  218.  
  219.     ifdef   Large_code
  220.     push    cs
  221.     endif
  222.  
  223.     call   sc_cget_
  224.  
  225. gmod_x:                         ;exit
  226.     ifdef    asm_386
  227.     movsx    eax,ax
  228.     endif
  229.  
  230.     epilog
  231. sc_gmod_ endp
  232.  
  233.  
  234. ;------------------------
  235. ;       sc_smod_                set a new screen mode
  236. ;------------------------
  237. ;                               Usage:  sc_smod(newmode);
  238. ;
  239. ;                               int sc_smod(int newmode);
  240.  
  241.     public  sc_smod_
  242.  
  243. sc_smod_ proc
  244.     parm386<<newmode,dword>>
  245.     parm86<<newmode,word>>
  246.     prolog
  247.  
  248.     ifdef   Large_data
  249.     mov     ax,seg dgroup
  250.     mov     ds,ax
  251.     endif
  252.  
  253.     mov     al,sc_adp_      ;get crt adapter type
  254.     cmp     al,NOADP        ;already determined?
  255.     jne     modset          ;else find out
  256.  
  257.     ifdef   Large_code
  258.     push    cs
  259.     endif
  260.  
  261.     call   sc_gmod_         ;get adapter mode
  262.  
  263. modset: mov     eax,newmode     ;al,newmode
  264.     mov     ah,mode         ;set mode command
  265.     int     video           ;set new mode
  266.  
  267.     ifdef   Large_code
  268.     push    cs
  269.     endif
  270.  
  271.     call   sc_gmod_         ;remember new values
  272.  
  273.     ifdef    asm_386
  274.     movsx    eax,ax
  275.     endif
  276.  
  277.     epilog
  278. sc_smod_ endp
  279.  
  280.  
  281. ;----------------------
  282. ;       sc_sattr_               set character attribute
  283. ;----------------------
  284. ;                Usage: sc_sattr_(attr)
  285. ;
  286. ;                               int sc_sattr_(int attr);
  287.  
  288.     public  sc_sattr_
  289.  
  290. sc_sattr_ proc
  291.     parm386<<attr,dword>>
  292.     parm86<<attr,word>>
  293.     prolog
  294.  
  295.     ifdef   Large_data
  296.     mov     ax,seg dgroup
  297.     mov     ds,ax
  298.     endif
  299.  
  300.     mov     eax,attr        ;get attribute
  301.     mov     _sc_attr_,al
  302.  
  303.     epilog
  304. sc_sattr_ endp
  305.  
  306.  
  307. ;---------------------
  308. ;       sc_font_                set new character font
  309. ;---------------------
  310. ;                               Usage: sc_font_(fonts);
  311. ;
  312. ;                               int sc_font_(struct FONT *fonts);
  313.  
  314.     public  sc_font_
  315.  
  316. sc_font_ proc
  317.     parms<<fonts,ptr>>
  318.     prolog
  319.     push    es              ;save es - we'll use it
  320.  
  321.     ifdef   Large_data
  322.     mov     ax,seg dgroup
  323.     mov     ds,ax
  324.     endif
  325.  
  326.     loadptr les,edi,fonts   ;FONT structure
  327.     mov     ah,011h         ;load font command
  328.     mov     al,[edi]        ;type
  329.     mov     ecx,[edi+1]     ;count of characters
  330.     mov     ebx,[edi+3]     ;block,bytes/character
  331.     mov     edx,[edi+5]     ;offset to table
  332.     mov     ebp,[edi+7]     ;address of table
  333.  
  334.     ifdef   Large_data
  335.     mov     si,[edi+7]      ;segment
  336.     push    si
  337.     pop     es              ;es:ebp points to table
  338.     else
  339.     push    ds
  340.     pop     es              ;use current segment
  341.     endif
  342.  
  343.     int     10h             ;do interrupt
  344.     mov     eax,1130h       ;now get rows
  345.     int     10h
  346.     mov     dh,0
  347.     mov     sc_rows_,edx    ;# rows per screen
  348.     pop     es              ;restore es
  349.  
  350.     ifdef    asm_386
  351.     movsx    eax,ax
  352.     endif
  353.  
  354.     epilog
  355. sc_font_ endp
  356.  
  357.  
  358. ;---------------------
  359. ;       _sc_adpt_               test display adapter
  360. ;---------------------
  361. ;                               Usage: _sc_adpt_(addr);
  362. ;
  363. ;                               int _sc_adpt_(int addr);
  364.  
  365.     public  _sc_adpt_
  366.  
  367. _sc_adpt_ proc
  368.     parm386<<addr,dword>>
  369.     parm86<<addr,word>>
  370.     prolog
  371.  
  372.     mov     edx,addr        ;get mem address
  373.     mov     al,0fh          ;mov cursor
  374.     out     dx,al
  375.     inc     dx
  376.     in      al,dx           ;save old
  377.     mov     bh,al
  378.     mov     al,5ah          ;mov cursor
  379.     out     dx,al
  380.     jmp     $+2             ;kill some time
  381.     jmp     $+2
  382.     jmp     $+2
  383.     in      al,dx           ;where is it now?
  384.     cmp     al,5ah          ;same place
  385.     mov     al,bh           ;restore old
  386.     out     dx,al
  387.     jne     fail
  388.  
  389.     mov     eax,1           ;true
  390.     jmp     adpt_x
  391.  
  392. fail:   xor     eax,eax
  393.  
  394. adpt_x: epilog
  395. _sc_adpt_ endp
  396.  
  397.  
  398. ;----------------------
  399. ;   _sc_s7bit_                  set bit 7 character attribute
  400. ;----------------------
  401. ;                               Usage: sc_s7bit_(TRUE/FALSE);
  402. ;
  403. ;                               int sc_s7bit_(int flag);
  404.  
  405.     public  sc_s7bit_
  406.  
  407. sc_s7bit_ proc
  408.     parm386<<flag,dword>>
  409.     parm86<<flag,word>>
  410.     prolog
  411.  
  412.     mov     eax,1003h       ;int 10 with ah=3
  413.     mov     ebx,flag        ;get attribute
  414.     int     video
  415.  
  416.     ifdef    asm_386
  417.     movsx    eax,ax
  418.     endif
  419.  
  420.     epilog
  421. sc_s7bit_ endp
  422.  
  423.  
  424. ;------------------------
  425. ;       sc_cget_                get current cursor location
  426. ;------------------------
  427. ;                               Usage: sc_cget_();
  428. ;
  429. ;                               int sc_cget_(void);
  430.  
  431.     public  sc_cget_
  432.  
  433. sc_cget_ proc
  434.     prolog
  435.  
  436.     ifdef   Large_data
  437.     mov     ax,seg dgroup
  438.     mov     ds,ax
  439.     endif
  440.  
  441.     mov     ah,readcur      ;command to read cursor
  442.     mov     ebx,_sc_page_   ;from current page
  443.     int     video           ;bios
  444.     mov     cl,dh           ;row to ecx
  445.     mov     ch,0
  446.     mov     dh,0            ;column in edx
  447.     mov     _sc_col_,edx    ;update globals
  448.     mov     _sc_row_,ecx
  449.  
  450.     ifdef    asm_386
  451.     movsx    eax,ax
  452.     endif
  453.  
  454.     epilog
  455. sc_cget_ endp
  456.  
  457.  
  458. ;------------------------
  459. ;       sc_cset_                 sets cursor at any location.
  460. ;------------------------      
  461. ;                 Usage:  sc_cset(new_col,new_row)
  462. ;
  463. ;                               int sc_cset(int new_col, int new_row);
  464.  
  465.     public  sc_cset_
  466.  
  467. sc_cset_ proc                    ; move cursor to x,y
  468.     parm386<<new_col,dword>,<new_row,dword>>
  469.     parm86<<new_col,word>,<new_row,word>>
  470.     prolog
  471.  
  472.     ifdef   Large_data
  473.     mov     ax,seg dgroup
  474.     mov     ds,ax
  475.     endif
  476.  
  477.     mov     edx,new_col     ; column
  478.     mov     eax,new_row     ; row
  479.     mov     _sc_col_,edx    ; update global
  480.     mov     _sc_row_,eax    ; update row global
  481.     mov     dh,al
  482.     mov     ebx,_sc_page_    ; set page
  483.     mov     bh,bl           ; to bh
  484.     mov     ah,setcur       ; set cursor location
  485.     int     video           ; call bios
  486.  
  487.     ifdef    asm_386
  488.     movsx    eax,ax
  489.     endif
  490.  
  491.     epilog
  492. sc_cset_ endp
  493.  
  494.  
  495. ;-----------------------
  496. ;       _sc_swup_        Scroll the screen up. The window is scrolled
  497. ;-----------------------        up nline lines. A zero nline will clear the
  498. ;                               window. Top left screen in 0,0.
  499. ;
  500. ;                               Usage: sc_swup_(nline,fromrow,fromcol,torow,tocol)
  501.  
  502.     public  sc_swup_
  503.  
  504. sc_swup_ proc
  505.     parm386<<nline,dword>,<fromrow,dword>,<fromcol,dword>,<torow,dword>,<tocol,dword>>
  506.     parm86<<nline,word>,<fromrow,word>,<fromcol,word>,<torow,word>,<tocol,word>>
  507.     prolog
  508.  
  509.     ifdef   Large_data
  510.     mov     ax,seg dgroup
  511.     mov     ds,ax
  512.     endif
  513.  
  514.     mov     eax,fromrow     ;starting row
  515.     mov     ch,al
  516.     mov     eax,fromcol     ;starting column
  517.     mov     cl,al
  518.     mov     eax,torow       ;ending row
  519.     mov     dh,al
  520.     mov     eax,tocol       ;ending column
  521.     mov     dl,al
  522.     mov     bh,_sc_attr_    ;current attribute
  523.     mov     eax,nline       ;number of lines
  524.     mov     ah,scrollup
  525.     int     video           ;do the scroll
  526.  
  527.     ifdef    asm_386
  528.     movsx    eax,ax
  529.     endif
  530.  
  531.     epilog
  532. sc_swup_ endp
  533.  
  534.  
  535. ;----------------------
  536. ;       sc_swdn_                scroll the screen down. the window is scrolled
  537. ;----------------------         down nline lines. A zero nline will clear the
  538. ;                               window. Top left of the screen in 0,0.
  539. ;
  540. ;                               Usage: sc_swdn_(nline,fromrow,fromcol,torow,tocol);
  541.  
  542.     public  sc_swdn_
  543.  
  544. sc_swdn_ proc
  545.     parm386<<nmline,dword>,<frmrow,dword>,<frmcol,dword>,<trow,dword>,<tcol,dword>>
  546.     parm86<<nmline,word>,<frmrow,word>,<frmcol,word>,<trow,word>,<tcol,word>>
  547.     prolog
  548.  
  549.     ifdef   Large_data
  550.     mov     ax,seg dgroup
  551.     mov     ds,ax
  552.     endif
  553.  
  554.     mov     eax,frmrow      ;starting row
  555.     mov     ch,al
  556.     mov     eax,frmcol      ;starting column
  557.     mov     cl,al
  558.     mov     eax,trow        ;ending row
  559.     mov     dh,al
  560.     mov     eax,tcol        ;ending column
  561.     mov     dl,al
  562.     mov     bh,_sc_attr_    ;current attribute
  563.     mov     eax,nmline       ;number of lines
  564.     mov     ah,scrolldn
  565.     int     video           ;do the scroll
  566.  
  567.     epilog
  568. sc_swdn_ endp
  569.  
  570.  
  571. ;---------------------
  572. ;       _sc_csof_        turn cursor off.
  573. ;---------------------
  574. ;                               Usage:  sc_csof_();
  575. ;
  576. ;                               int sc_csof_(void);
  577.  
  578.     public  sc_csof_
  579.  
  580. sc_csof_ proc
  581.     prolog
  582.  
  583.     ifdef   Large_data
  584.     mov     ax,seg dgroup
  585.     mov     ds,ax
  586.     endif
  587.  
  588.     cmp     _sc_mode_,4     ;see if graphics
  589.     jc      text_coff
  590.     cmp     _sc_mode_,7
  591.     jnz     no_cur
  592.  
  593. text_coff:
  594.     mov     ecx,0f00h       ;should turn cursor off
  595. new_cur:
  596.     mov     ah,curtype      ;set a new cursor type
  597.     int     video
  598.  
  599. no_cur: 
  600.     ifdef    asm_386
  601.     movsx    eax,ax
  602.     endif
  603.  
  604.     epilog
  605. sc_csof_ endp
  606.  
  607.  
  608.  
  609. ;-----------------------
  610. ;       sc_cson_                turn cursor back on.
  611. ;-----------------------
  612. ;                               Usage:  sc_cson_();
  613. ;
  614. ;                               int sc_cson_(void);
  615.     public  sc_cson_
  616.  
  617. sc_cson_ proc
  618.     prolog
  619.  
  620.     ifdef   Large_data
  621.     mov     ax,seg dgroup
  622.     mov     ds,ax
  623.     endif
  624.  
  625.     mov     ecx,0c0dh       ;assume monocrome
  626.     cmp     _sc_mode_,7     ;true is mono
  627.     jz      new_c           ;set it
  628.     mov     ecx,0607h       ;assume color card in text mode
  629.     cmp     _sc_mode_,4     ;color text is 0 to 3
  630.     jc      new_c
  631.     jmp     sc_csx
  632.  
  633. new_c:  mov     ah,curtype      ;set a new cursor type
  634.     int     video
  635.  
  636.     ifdef    asm_386
  637.     movsx    eax,ax
  638.     endif
  639.  
  640. sc_csx: epilog
  641. sc_cson_ endp
  642.  
  643.  
  644. ;------------------
  645. ;       sc_getc_                screen input (read character from the screen).
  646. ;------------------
  647. ;                               Usage:  character = sc_getc();
  648. ;
  649. ;                               int sc_cgetc(void);
  650.  
  651.     public  sc_getc_
  652.  
  653. sc_getc_ proc
  654.     prolog
  655.  
  656.     mov     bh,0            ;only read from page 0
  657.     mov     ah,readch       ;code to read a character
  658.     int     video           ;al is letter, ah=attributes
  659.     or      al,al           ;zero returned instead of blank in graphics mode
  660.     jnz     ret_ch
  661.     mov     al,' '
  662.  
  663. ret_ch: mov     ah,0            ;kill the attributes
  664.  
  665.     ifdef    asm_386
  666.     movsx    eax,ax
  667.     endif
  668.  
  669.     epilog
  670. sc_getc_ endp
  671.  
  672.  
  673. ;-------------------
  674. ;       sc_putc_                output char & attribute
  675. ;-------------------
  676. ;                               Usage:  sc_putc_(char)
  677. ;
  678. ;                               int sc_putc_(char c);
  679.  
  680.     public  sc_putc_
  681.  
  682. sc_putc_ proc
  683.     parms<<c,byte>>
  684.     prolog
  685.  
  686.     ifdef   Large_data
  687.     mov     ax,seg dgroup
  688.     mov     ds,ax
  689.     endif
  690.  
  691.     mov     al,c            ;get character
  692.     mov     ecx,1           ;number of chars to write
  693.     mov     ebx,_sc_page_   ;write to page
  694.     mov     bh,bl
  695.     mov     bl,_sc_attr_    ;attribute
  696.     mov     ah,writeca      ;write char & attr command
  697.     int     video           ;do it
  698.  
  699.     ifdef    asm_386
  700.     movsx    eax,ax
  701.     endif
  702.  
  703.     epilog
  704. sc_putc_ endp
  705.  
  706.  
  707. ;------------------
  708. ;       sc_gwin_                get screen windo to buffer
  709. ;------------------
  710. ;                               Usage:  character = sc_gwin(page,buff);
  711. ;
  712. ;                               int sc_gwin(int page, char *buff);
  713.  
  714.     public  sc_gwin_
  715.  
  716. sc_gwin_ proc
  717.     parm386<<pg,dword>,<buff,ptr>>
  718.     parm86<<pg,word>,<buff,ptr>>
  719.     prolog
  720.  
  721.     ifdef   Large_data
  722.     mov     ax,seg dgroup
  723.     mov     ds,ax
  724.     endif
  725.  
  726.     push    es              ;save es for segment
  727.     mov     edx,_rowst_     ;rows to edx
  728.     loadptr les,edi,buff    ;buffer pointer
  729.     mov     ebx,pg          ;read from page
  730.     xchg    bh,bl           ;***********
  731.  
  732. gwin1:  mov     ecx,_colst_     ;columns to ecx
  733.  
  734. gwin2:  push    edx
  735.     mov     dh,dl           ;set dh,dl to row,col
  736.     mov     dl,cl           ;columns to dl for curset
  737.     mov     ah,02
  738.     int     video           ;do interrupt for curset
  739.     pop     edx
  740.     mov     ah,readch       ;code to read a character
  741.     int     video           ;al is letter, ah=attributes
  742.     mov     es:[edi],eax    ;store char and attr
  743.     inc     edi             ;next buffer location
  744.     inc     edi
  745.     inc     ecx             ;next column
  746.     cmp     ecx,_colen_
  747.     jle     gwin2
  748.  
  749.     inc     edx             ;next row
  750.     cmp     edx,_rowen_     ;last row?
  751.     jle     gwin1
  752.  
  753.     pop     es              ;restore segment pointer
  754.  
  755.     ifdef    asm_386
  756.     movsx    eax,ax
  757.     endif
  758.  
  759.     epilog
  760. sc_gwin_ endp
  761.  
  762.  
  763. ;------------------
  764. ;       _sc_pwin_        put buffer to screen windo 
  765. ;------------------
  766. ;                               Usage:  character = sc_pwin(page,buff);
  767. ;
  768. ;                               int sc_pwin(int page, char *buff);
  769.  
  770.     public  sc_pwin_
  771.  
  772. sc_pwin_ proc
  773.     parm386<<pge,dword>,<buff1,ptr>>
  774.     parm86<<pge,word>,<buff1,ptr>>
  775.     prolog
  776.     push    es              ;save es for segment
  777.  
  778.     ifdef   Large_data
  779.     mov     ax,seg dgroup
  780.     mov     ds,ax
  781.     endif
  782.  
  783.     mov     edx,_rowst_     ;rows to edx
  784.     loadptr les,edi,buff1   ;buffer pointer
  785.     mov     ebx,pge         ;write to  page
  786.     xchg    bh,bl           ;*************
  787.  
  788. pwin1:  mov     ecx,_colst_     ;columns to ecx
  789.  
  790. pwin2:  push    edx
  791.     mov     dh,dl           ;set dh,dl to row,col
  792.     mov     dl,cl           ;columns to dl for curset
  793.     mov     ah,02
  794.     int     video           ;set cursor
  795.     pop     edx
  796.     mov     eax,es:[edi]    ;get attr/char
  797.     mov     bl,ah           ;attribute to bl
  798.     push    ecx             ;save column count
  799.     mov     ecx,1           ;write one char
  800.     mov     ah,writeca      ;code to read a character
  801.     int     video           ;al is letter, ah=attributes
  802.     pop     ecx             ;restore col count
  803.     inc     edi             ;next buffer location
  804.     inc     edi
  805.     inc     ecx             ;next column
  806.     cmp     ecx,_colen_
  807.     jle     pwin2
  808.  
  809.     inc     edx             ;next row
  810.     cmp     edx,_rowen_     ;last row?
  811.     jle     pwin1
  812.  
  813.     pop     es              ;restore segment pointer
  814.     ifdef    asm_386
  815.     movsx    eax,ax
  816.     endif
  817.  
  818.     epilog
  819. sc_pwin_ endp
  820.  
  821.     endcseg sc_gmod_
  822.     end
  823.  
  824.