;       SCCSID = @(#)bvssubs.asm        6.1 90/11/16
;SCCSID = @(#)bvssubs.asm       6.11 90/02/27
        PAGE    58,132
        TITLE   BvsSubs.Asm -- Base Video Subsystem Buffer Subroutines
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SOURCE FILE NAME:   BvsSubs.Asm                                     */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Base Video Subsystem Buffer Subroutines         */
;/*                                                                     */
;/* COPYRIGHT:  na                                                      */
;/*                                                                     */
;/* STATUS:     na                                                      */
;/*                                                                     */
;/* NOTES:       Executes on level 3 - Protect Mode ONLY                */
;/*                                                                     */
;/*    DEPENDENCIES:    None                                            */
;/*                                                                     */
;/*    RESTRICTIONS:    None                                            */
;/*                                                                     */
;/*    PATCH LABEL:     na                                              */
;/*                                                                     */
;/* ENTRY POINTS: BvsReadCellStr, BvsReadCharStr, BvsScrollDn,          */
;/*               BvsScrollLf, BvsScrollRt, BvsScrollUp,                */
;/*               BvsWrtCellStr, BvsWrtCharStr, BvsWrtCharStrAtt,       */
;/*               BvsWrtNAttr, BvsWrtNCell, BvsWrtNChar                 */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/************************ END OF SPECIFICATIONS ************************/

        .xlist
        INCLUDE bvscb.inc               ;BVS Data Structures
        INCLUDE bvsparms.inc            ;BVS Parameter Equates
        INCLUDE bvsextrn.inc            ;BVS external definitions       ;@T52
        INCLUDE error2.inc              ;Error Equates
        INCLUDE struc.inc               ;Structured Macros
        INCLUDE dc1segs.inc                                             ;MDLL
        .list

        .386p                   ;@D549

        extrn   AllVDH:NEAR             ;Common VDH call routine in BVSMAIN
        extrn   VIOWRTNCELL:FAR
        extrn   VIOSETCURPOS:FAR        ;                               @T31

BVSISEG SEGMENT WORD PUBLIC 'FAR_DATA' USE16    ;@D549             ;@T52;MDLL
BVSISEG ENDS

BVS3SEG SEGMENT BYTE PUBLIC 'CODE' USE16        ;@D549
        ASSUME  CS:CODE02                                               ;MDLL

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsReadCellStr                                  */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Read Cell String                                */
;/*                                                                     */
;/* FUNCTION:   The cells are read from the display                     */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The read is terminated if it comes to the end of the    */
;/*             screen.  The cells that are read are                    */
;/*             placed in the specified buffer.  The length of the cell */
;/*             string read is returned.                                */
;/*                                                                     */
;/* NOTES:   Executes on level 3, protect mode only                     */
;/*                                                                     */
;/* ENTRY POINT:  BvsReadCellStr                                        */
;/*   LINKAGE:  Call BvsReadCellStr from BVSMAIN                        */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = r_column      Starting column                         */
;/*     parmnm1 = r_row         Starting row                            */
;/*     parmnm2 = r_lenoff      Offset of Length                        */
;/*     parmnm3 = r_lensel      Selector of Length                      */
;/*     parmnm4 = r_stroff      Offset of String                        */
;/*     parmnm5 = r_strsel      Selector of String                      */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES:  None                                                   */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDHs                                    */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsReadCellStr
;    Call BufferUpdate w/AL=2 to read a string of cells
;End BvsReadCellStr

BvsReadCellStr PROC NEAR
        PUBLIC  BvsReadCellStr

        mov     [bp].vp_index,sx_ReadCellStr ;Set the subroutine index ;JOPT

AllRead LABEL   NEAR                    ;JOPT
        PUBLIC  AllRead

        mov     ax,[bp].r_row
        mov     [bp].vp_startrow,ax
        mov     ax,[bp].r_col
        mov     [bp].vp_startcol,ax     ;Set the row and column

        mov     ax,[bp].r_stroff
        mov     [bp].vp_offset,ax
        mov     ax,[bp].r_strsel
        mov     [bp].vp_selector,ax     ;Set the string address

        push    ds                      ;B700908
        lds     si,dword ptr [bp].r_lenoff
        mov     ax,[si]
        mov     [bp].vp_repeatlength,ax ;Setup the length

        Call    AllBuffer

        .if     <zero ax>
            mov     cx,[bp].vp_repeatlength
            mov     [si],cx             ;Return the length
        .endif
        pop     ds                      ;B700908

        ret
BvsReadCellStr ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsReadCharStr                                  */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Read Characters String                          */
;/*                                                                     */
;/* FUNCTION:   The characters are read from the display                */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The read is terminated if it comes to the end of the    */
;/*             screen.  The characters that are read are               */
;/*             placed in the specified buffer.  The length of the cell */
;/*             string read is returned.                                */
;/*                                                                     */
;/* NOTES:      Executes on level 3                                     */
;/*                                                                     */
;/* ENTRY POINT:  BvsReadCharStr                                        */
;/*   LINKAGE:  Call BvsReadCharStr from BVSMAIN                        */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = r_column      Starting column                         */
;/*     parmnm1 = r_row         Starting row                            */
;/*     parmnm2 = r_lenoff      Offset of Length                        */
;/*     parmnm3 = r_lensel      Selector of Length                      */
;/*     parmnm4 = r_stroff      Offset of String                        */
;/*     parmnm5 = r_strsel      Selector of String                      */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDHs                                    */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsReadCharStr
;    Call BufferUpdate w/AL=1 to read a string of characters
;End BvsReadCharStr

BvsReadCharStr PROC NEAR
        PUBLIC  BvsReadCharStr

        mov     [bp].vp_index,sx_ReadCharStr ;Set the subroutine index ;JOPT
        jmp     AllRead                 ;JOPT
BvsReadCharStr ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:  BvsScrollUp                                       */
;/*                                                                     */
;/* DESCRIPTIVE NAME:  Base Video Subsystem Scroll Up                   */
;/*                                                                     */
;/* FUNCTION:  Scrolls a portion of the video buffer up a specified     */
;/*            number of times.                                         */
;/*                                                                     */
;/* NOTES:  Executes on Level 3                                         */
;/*                                                                     */
;/* ENTRY POINT:  BvsScrollUp                                           */
;/*   LINKAGE:  Call BvsScrollUp from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = s_celloff     Offset of fill Cell                     */
;/*     parmnm1 = s_cellsel     Selector of fill Cell                   */
;/*     parmnm2 = s_times       Number of times to scroll               */
;/*     parmnm3 = s_rightcol    Rightmost column of window              */
;/*     parmnm4 = s_botrow      Bottom row of window                    */
;/*     parmnm5 = s_leftcol     Leftmost column of window               */
;/*     parmnm6 = s_toprow      Top row of window                       */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid TopRow value                                    */
;/*             Invalid LeftCol value                                   */
;/*                                                                     */
;/* EFFECTS:  None                                                      */
;/*                                                                     */
;/* INTERNAL REFERENCES:  BVSCBsg                                       */
;/*   ROUTINES:  CheckScrollParms                                       */
;/*                                                                     */
;/* EXTERNAL REFERENCES:  None                                          */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/*                                                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsScrollUp
;    Call BufferUpdate w/AL=3 to scroll the display up
;End BvsScrollUp

BvsScrollUp PROC NEAR
        PUBLIC  BvsScrollUp

        mov     al,sx_ScrollUp

AllScroll LABEL NEAR                    ;JOPT
        PUBLIC  AllScroll

        cbw
        mov     [bp].vp_index,ax        ;Set the subroutine index

        mov     di,bvs_ScratchRect      ;Use if WrtThru is set
        mov     ax,[bp].s_toprow
        mov     [bp].vp_startrow,ax
        mov     ax,[bp].s_leftcol
        mov     [bp].vp_startcol,ax     ;Set the row and column

        mov     ax,[bp].s_botrow
        mov     [bp].vp_secondrow,ax
        mov     ax,[bp].s_rightcol
        mov     [bp].vp_secondcol,ax    ;Set the row and column

        mov     ax,[bp].s_celloff
        mov     [bp].vp_secondoff,ax
        mov     ax,[bp].s_cellsel
        mov     [bp].vp_secondsel,ax    ;Set the cell address

        mov     ax,[bp].s_times
        mov     [bp].vp_repeatlength,ax ;Set the number of times


        .if     <[bx].bvs_CA_pid eq bx> ;No CAs are active
            Call    AllBuffer
        .else                           ;CAs active, scroll LVB then copy to PVB
            or      [bp].vp_flags,vp_f_physical ;LVB only scrolling
            or      [bp].vp_flags,vp_f_logical  ;@B43 if ca's are active
                                                ;@B43   set Update_PVB_Flag
            Call    AllBuffer
            .if     <zero ax>
                mov     [bp].vp_index,sx_CopyRect ; Index of subroutine

                mov     ax,[bp].s_toprow ; (ax) = top side of copy rect
                mov     [bp].vp_startrow,ax ; top border of rectangle
                mov     ax,[bp].s_leftcol ; (ax) = left side of copy rect
                mov     [bp].vp_startcol,ax ; left border of rectangle
                mov     ax,[bp].s_botrow ; (ax) = bottom side of copy rect
                mov     [bp].vp_secondrow,ax ; bottom border of rectangle
                mov     ax,[bp].s_rightcol ; (ax) = right side of copy rect
                mov     [bp].vp_secondcol,ax ; right border of rectangle

                call    AllBuffer       ; execute the function
            .endif
        .endif
        ret
BvsScrollUP ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:  BvsScrollDn                                       */
;/*                                                                     */
;/* DESCRIPTIVE NAME:  Base Video Subsystem Scroll Down                 */
;/*                                                                     */
;/* FUNCTION:  Scrolls a portion of the video buffer down a specified   */
;/*            number of times.                                         */
;/*                                                                     */
;/* NOTES:  Executes on Level 3                                         */
;/*                                                                     */
;/* ENTRY POINT:  BvsScrollDn                                           */
;/*   LINKAGE:  Call BvsScrollDn from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = s_celloff     Offset of fill Cell                     */
;/*     parmnm1 = s_cellsel     Selector of fill Cell                   */
;/*     parmnm2 = s_times       Number of times to scroll               */
;/*     parmnm3 = s_rightcol    Rightmost column of window              */
;/*     parmnm4 = s_botrow      Bottom row of window                    */
;/*     parmnm5 = s_leftcol     Leftmost column of window               */
;/*     parmnm6 = s_toprow      Top row of window                       */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid TopRow value                                    */
;/*             Invalid LeftCol value                                   */
;/*                                                                     */
;/* EFFECTS:  None                                                      */
;/*                                                                     */
;/* INTERNAL REFERENCES:  BVSCBsg                                       */
;/*   ROUTINES:  CheckScrollParms                                       */
;/*                                                                     */
;/* EXTERNAL REFERENCES:  None                                          */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/*                                                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsScrollDn
;    Call BufferUpdate w/AL=4 to scroll the display down
;End BvsScrollDn

BvsScrollDn PROC NEAR
        PUBLIC  BvsScrollDn

        mov     al,sx_ScrollDn
        jmp     AllScroll               ;JOPT
BvsScrollDn ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:  BvsScrollLf                                       */
;/*                                                                     */
;/* DESCRIPTIVE NAME:  Base Video Subsystem Scroll Left                 */
;/*                                                                     */
;/* FUNCTION:  Scrolls a portion of the video buffer left a specified   */
;/*            number of times.                                         */
;/*                                                                     */
;/* NOTES:  Executes on Level 3                                         */
;/*                                                                     */
;/* ENTRY POINT:  BvsScrollLf                                           */
;/*   LINKAGE:  Call BvsScrollLf from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = s_celloff     Offset of fill Cell                     */
;/*     parmnm1 = s_cellsel     Selector of fill Cell                   */
;/*     parmnm2 = s_times       Number of times to scroll               */
;/*     parmnm3 = s_rightcol    Rightmost column of window              */
;/*     parmnm4 = s_botrow      Bottom row of window                    */
;/*     parmnm5 = s_leftcol     Leftmost column of window               */
;/*     parmnm6 = s_toprow      Top row of window                       */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid TopRow value                                    */
;/*             Invalid LeftCol value                                   */
;/*                                                                     */
;/* EFFECTS:  None                                                      */
;/*                                                                     */
;/* INTERNAL REFERENCES:  BVSsg                                         */
;/*   ROUTINES:  CheckScrollParms                                       */
;/*                                                                     */
;/* EXTERNAL REFERENCES:  None                                          */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/*                                                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsScrollLf
;    Call BufferUpdate w/AL=5 to scroll the display left
;End BvsScrollLf

BvsScrollLf PROC NEAR
        PUBLIC  BvsScrollLf

        mov     al,sx_ScrollLf
        jmp     AllScroll               ;JOPT
BvsScrollLf ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:  BvsScrollRt                                       */
;/*                                                                     */
;/* DESCRIPTIVE NAME:  Base Video Subsystem Scroll Right                */
;/*                                                                     */
;/* FUNCTION:  Scrolls a portion of the video buffer right a specified  */
;/*            number of times.                                         */
;/*                                                                     */
;/* NOTES:  Executes on Level 3                                         */
;/*                                                                     */
;/* ENTRY POINT:  BvsScrollRt                                           */
;/*   LINKAGE:  Call BvsScrollRt from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = s_celloff     Offset of fill Cell                     */
;/*     parmnm1 = s_cellsel     Selector of fill Cell                   */
;/*     parmnm2 = s_times       Number of times to scroll               */
;/*     parmnm3 = s_rightcol    Rightmost column of window              */
;/*     parmnm4 = s_botrow      Bottom row of window                    */
;/*     parmnm5 = s_leftcol     Leftmost column of window               */
;/*     parmnm6 = s_toprow      Top row of window                       */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid TopRow value                                    */
;/*             Invalid LeftCol value                                   */
;/*                                                                     */
;/* EFFECTS:  None                                                      */
;/*                                                                     */
;/* INTERNAL REFERENCES:  BVSCBsg                                       */
;/*   ROUTINES:  CheckScrollParms                                       */
;/*                                                                     */
;/* EXTERNAL REFERENCES:  None                                          */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/*                                                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsScrollRt
;    Call BufferUpdate w/AL=6 to scroll the display right
;End BvsScrollRt

BvsScrollRt PROC NEAR
        PUBLIC  BvsScrollRt

        mov     al,sx_ScrollRt
        jmp     AllScroll               ;JOPT
BvsScrollRt ENDP

BVS3SEG ENDS                                                            ;MDLL



CTEXT_TUNE5 SEGMENT BYTE PUBLIC 'CODE' USE16                       ;MDLL;@D549
        ASSUME  CS:CODE02                                               ;MDLL

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtCellStr                                   */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write Cell String                               */
;/*                                                                     */
;/* FUNCTION:   The cells are read from the cell string buffer and put  */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.                                                 */
;/*                                                                     */
;/* NOTES:      Executes on level 3, protect mode only                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtCellStr                                         */
;/*   LINKAGE:  Call BvsWrtCellStr from BVSMAIN                         */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_length      Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of String                        */
;/*     parmnm4 = w_strsel      Selector of String                      */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtCellStr
;    Call BufferUpdate w/AL=7 to write a string of cells
;End BvsWrtCellStr

BvsWrtCellStr PROC NEAR
        PUBLIC  BvsWrtCellStr

        mov     al,sx_WriteCellStr

AllWrite LABEL  NEAR                    ;JOPT
        PUBLIC  AllWrite

        cbw
        mov     [bp].vp_index,ax        ;Set the subroutine index

        mov     ax,[bp].w_row
        mov     [bp].vp_startrow,ax
        mov     ax,[bp].w_col
        mov     [bp].vp_startcol,ax     ;Set the row and column

        mov     ax,[bp].w_stroff
        mov     [bp].vp_offset,ax
        mov     ax,[bp].w_strsel
        mov     [bp].vp_selector,ax     ;Set the string address

        mov     ax,[bp].w_length
        mov     [bp].vp_repeatlength,ax ;Setup the length

        jmp     short AllBuffer         ;JOPT
BvsWrtCellStr ENDP

;/*********************** START OF SPECIFICATIONS ***********************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtCharStr                                   */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write Char String                               */
;/*                                                                     */
;/* FUNCTION:   The chars are read from the string buffer and put       */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.                                                 */
;/*                                                                     */
;/* NOTES:      Executes on level 3, Protect mode only                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtCharStr                                         */
;/*   LINKAGE:  Call BvsWrtCharStr from BVSMAIN                         */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_length      Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of String                        */
;/*     parmnm4 = w_strsel      Selector of String                      */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtCharStr
;    Call BufferUpdate w/AL=8 to write a string of characters
;End BvsWrtCharStr

BvsWrtCharStr PROC NEAR
        PUBLIC  BvsWrtCharStr

        mov     al,sx_WriteCharStr
        jmp     short AllWrite          ;JOPT
BvsWrtCharStr ENDP

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtCharStrAtt                                */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write Char String with an attribute             */
;/*                                                                     */
;/* FUNCTION:   The chars are read from the string buffer and put       */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.  The specified attribute is                     */
;/*             written at the attribute positions.                     */
;/*                                                                     */
;/* NOTES:      Executes on level 3, Protect mode ONLY                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtCharStrAtt                                      */
;/*   LINKAGE:  Call BvsWrtCharStrAtt from BVSMAIN                      */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) after BP adjustment: */
;/*     userip  = w_attroff     Offset of Attribute                     */
;/*     usercs  = w_attrsel     Selector of Attribute                   */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_length      Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of String                        */
;/*     parmnm4 = w_strsel      Selector of String                      */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtCharStrAtt
;    Call BufferUpdate w/AL=9 to write a string of chars with attr
;End BvsWrtCharStrAtt

BvsWrtCharStrAtt PROC NEAR
        PUBLIC  BvsWrtCharStrAtt

        mov     [bp].vp_index,sx_WriteCharStrAtt

        mov     ax,[bp].wa_row
        mov     [bp].vp_startrow,ax
        mov     ax,[bp].wa_col
        mov     [bp].vp_startcol,ax     ;Set the row and column

        mov     ax,[bp].wa_stroff
        mov     [bp].vp_offset,ax
        mov     ax,[bp].wa_strsel
        mov     [bp].vp_selector,ax     ;Set the string address

        mov     ax,[bp].wa_attroff
        mov     [bp].vp_secondoff,ax
        mov     ax,[bp].wa_attrsel
        mov     [bp].vp_secondsel,ax    ;Set the attribute address

        mov     ax,[bp].wa_length
        mov     [bp].vp_repeatlength,ax ;Setup the length

AllBuffer LABEL NEAR                    ;JOPT
        PUBLIC  AllBuffer

        push    ds
        mov     ds,es:bvsi_bvssel                                       ;@T52
        .if     <[bx].bvs_CA_pid ne bx> or                              ;@B43
        test    [bx].bvs_flags,bvs_f_wrtthru

        .if     <nz>                    ;Force LVB update if WriteThru on
            or      [bp].vp_flags,vp_f_logical
        .endif
        pop     ds

        .if     <[bp].vp_parmlength ne 46> ; Is packet already ready? ;JOPT
            mov     ax,es:bvsi_lvbsel   ;@TB11                          ;@T52
            mov     [bp].vp_lvbsel,ax       ;@TB11
            mov     [bp].vp_parmlength,26 ;Set parameter list length
        .endif
        mov     di,fn_BufferUpdate

        jmp     AllVDH                  ;JOPT
BvsWrtCharStrAtt ENDP

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtNAttr                                     */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write N attributes                              */
;/*                                                                     */
;/* FUNCTION:   N attributes are written to the screen                  */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.                                                 */
;/*                                                                     */
;/* NOTES:      Executes on level 3, protect mode only                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtNAttr                                           */
;/*   LINKAGE:  Call BvsWrtNAttr from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_times       Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of Attribute                     */
;/*     parmnm4 = w_strsel      Selector of Attribute                   */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtNAttr
;    Call BufferUpdate w/AL=11 to write a repeated attribute
;End BvsWrtNAttr

BvsWrtNAttr PROC NEAR
        PUBLIC  BvsWrtNAttr

        mov     al,sx_WriteNAttr
        jmp     AllWrite                ;JOPT
BvsWrtNAttr ENDP

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtNCell                                     */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write N cells                                   */
;/*                                                                     */
;/* FUNCTION:   N cells are written to the screen                       */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.                                                 */
;/*                                                                     */
;/* NOTES:      Executes on level 3, protect mode ONLY                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtNCell                                           */
;/*   LINKAGE:  Call BvsWrtNCell from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_times       Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of Cell                          */
;/*     parmnm4 = w_strsel      Selector of Cell                        */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtNCell
;    Call BufferUpdate w/AL=12 to write a repeated cell
;End BvsWrtNCell

BvsWrtNCell PROC NEAR
        PUBLIC  BvsWrtNCell

        mov     al,sx_WriteNCell
        jmp     AllWrite                ;JOPT
BvsWrtNCell ENDP

;/********************** START OF SPECIFICATIONS ************************/
;/*                                                                     */
;/* SUBROUTINE NAME:    BvsWrtNChar                                     */
;/*                                                                     */
;/* DESCRIPTIVE NAME:   Write N characters                              */
;/*                                                                     */
;/* FUNCTION:   N characters are written to the screen                  */
;/*             starting at the specified row/column location.          */
;/*             Line wrap occurs if the end of a line is reached.       */
;/*             The write is terminated if it comes to the end of the   */
;/*             screen.                                                 */
;/*                                                                     */
;/* NOTES:      Executes on level 3, protect mode ONLY                  */
;/*                                                                     */
;/* ENTRY POINT:  BvsWrtNChar                                           */
;/*   LINKAGE:  Call BvsWrtNChar from BVSMAIN                           */
;/*                                                                     */
;/* INPUT:  StackFrame and Registers (see BVSMAIN) with:                */
;/*     parmn   = w_column      Starting column                         */
;/*     parmnm1 = w_row         Starting row                            */
;/*     parmnm2 = w_times       Number of times to write                */
;/*     parmnm3 = w_stroff      Offset of Character                     */
;/*     parmnm4 = w_strsel      Selector of Character                   */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR: Invalid Row value                                       */
;/*             Invalid Column value                                    */
;/*                                                                     */
;/* EFFECTS:    None                                                    */
;/*                                                                     */
;/* INTERNAL REFERENCES: BVSCB                                          */
;/*   ROUTINES: None                                                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES: None                                           */
;/*   ROUTINES: BufferUpdate in VDH                                     */
;/************************ END OF SPECIFICATIONS ************************/

;Begin BvsWrtNChar
;    Call BufferUpdate w/AL=10 to write a repeated character
;End BvsWrtNChar

BvsWrtNChar PROC NEAR
        PUBLIC  BvsWrtNChar

        mov     al,sx_WriteNChar
        jmp     AllWrite                ;JOPT
BvsWrtNChar ENDP

ClearScreen PROC NEAR
        PUBLIC  ClearScreen
        push    ax                      ; save ax
        push    ds
        push    bvs_ttycell             ; Cell to use for blanking
        push    -1                      ; screen size (will be adjusted)
        push    bx                      ; row 0
        push    bx                      ; col 0
        push    bx                      ; Always use 0 since VioRegister
                                        ;   is not supported for AVIO
        test    [bp].p_regax,rf_WrtNCell                                ;@T46
        .if     <nz>                    ; Alternate I/O present         ;@T31
            Call    VIOWRTNCELL         ; Clear the screen
        .else                                                           ;@T46
            bvsfunc vf_WrtNCell 6 vp_f_attrxlate ; Clear the screen     ;J-KKJ
        .endif                                                          ;@T46

        push    bx                      ; row 0                         ;@T31
        push    bx                      ; col 0                         ;@T31
        push    bx                      ; Always use 0 since VioRegister
                                        ;   is not supported for AVIO
        test    [bp].p_regax,rf_SetCurPos                               ;@T46
        .if     <nz>                    ; Alternate I/O present         ;@T46
            Call    VIOSETCURPOS        ; Set cursor position to (0,0)  ;@T31
        .else                           ;                               ;@T46
            bvsfunc vf_SetCurPos 3      ; Set cursor position           ;@T31
        .endif
        pop     ax                      ; restore ax
        ret
ClearScreen ENDP

CTEXT_TUNE5 ENDS                                                        ;MDLL
        END

;JOPT = 03/29/89 STJ, Replace CALL/RET with jumps through subroutines
;B700908 = 04/06/89 STJ, Save/Restore DS in AllRead
;@T31 = 05/18/89 TPL, PhilipL suggested changes for DCR 132, B783850
;@TB11 = 05/24/89 TLB, Changes requested by PhilipL via PTR B783954.
;@T46 = 09/05/89 TPL, Use the compress registration mask from VIO, PTR B70????
;@D549 = 11/02/89 CJJ, Seltable changes due to rangeless sessions, DCR 549
;@T52  = 02/08/90 TPL, DCR 704 work
;J-KKJ = 02/12/90 KKJ, Set CGA attribute bit at ClearScreen, P711352
;@B43  = 02/19/90 WKB, Set Update_LVB_Flag if CA's are active, B788133
;MDLL  = 01/10/94 BJN, Page Tune segments for Merged DLL.
