;# SCCSID = @(#)vioxxx.asm      6.5 92/02/13
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************
        PAGE    58,132
        SUBTTL  VIOxxx calls
        TITLE   VIOXXX.ASM
;******************************************************************************
;*******   C H A N G E       H I S T O R Y   **********************************
;******************************************************************************
;@A0= support for VIOREDRAWSIZE (DCR 85)
;     02-10-88
;$A0= preserve return code from VIOROUT in VIOWRTTTY
;     9-18-86 (7.57)
;$A1= match latest (9-29-86) DOSSYSTRACE document
;     9-30-86 (7.61)
;$Z7= save/restore SI when calling DOSSYSTRACE
;     07-08-87
;$Z8= new System Trace parameters support
;     06-04-87
;$Z9= add new API for 1.10 @@11
;     11-03-86
;MMIO= Implement Memory-Mapped I/O performance trace hooks
;      11-03-88
;@T1 = 03/13/89 TPL, Fix MMIO errors reported by Chuck Raby, PTR B701685
;@T2 = 04/03/89 TPL, Sizzle work, PTR B701685
;@T3 = 05/02/89 TPL, MMIO fix, PTR B702148
;@T4 = 05/16/89 TPL, MMIO fix, PTR B702421
;DTBB1= 08/21/89 WKB, Add Dynamic Trace in place of Static Trace (DOSSYSTRACE)
;D549 = 11/09/89 WKB, DCR549 Changes
;D811 = 11/30/89 MS, DCR 811
;@T52 = 01/15/90 TPL, DCR 704 work
;@B44= 02/12/90 WKB, Translate VioShowBuf error return codes, PTR B702421
;@B50 = 03/21/90 WKB, Transparent popup over diff cp disallowed, B711349
;@C42  03/26/90  CJJ, SL85039 Don't allow VioPopups until Shell has done a
;                VioSavRedrawWait.
;@T14 = 03/28/90 TPL, Remove duplication of functions
;@B50f= 04/19/90 TPL, @B50 fix, B712601
;@T80 = 02/06/92 TPL, Don't use the reserved register FS, B732479
;MDLL = 01/10/94 BJN, Page Tune segments for Merged DLL.

.xlist
include error2.inc                                                      ;@B44
include struc.inc
include infoseg.inc
include viomac.inc                                                      ;@T2
include vioequ.inc
include vioidata.inc
include viocdata.inc
.list
.386p                                                                   ;D549

extrn   viorout:NEAR            ;internal call external definitions
extrn   check_dbc:NEAR          ;

extrn   DOSGETCP:FAR                                                    ;Proto

IFDEF MMIOPH
extrn   MMIO_post:NEAR                                                  ;MMIO
ENDIF

public  VIOGETMODE
public  VIOGETMODE_POSTDT                                               ;DTBB1
public  VIOGETPHYSBUF
public  VIOGETPHYSBUF_POSTDT                                            ;DTBB1
public  VIOGETCURPOS
public  VIOGETCURPOS_POSTDT                                             ;DTBB1
public  VIOSETCURPOS
public  VIOSETCURPOS_POSTDT                                             ;DTBB1
public  VIOGETCURTYPE
public  VIOGETCURTYPE_POSTDT                                            ;DTBB1
public  VIOGETBUF
public  VIOGETBUF_POSTDT                                                ;DTBB1
public  VIOSETCURTYPE
public  VIOSETCURTYPE_POSTDT                                            ;DTBB1
public  VIOSETMODE
public  VIOSETMODE_POSTDT                                               ;DTBB1
public  VIOSHOWBUF
public  VIOSHOWBUF_POSTDT                                               ;DTBB1
public  VIOREADCHARSTR
public  VIOREADCHARSTR_POSTDT                                           ;DTBB1
public  VIOREADCELLSTR
public  VIOREADCELLSTR_POSTDT                                           ;DTBB1
public  VIOWRTNCHAR
public  VIOWRTNCHAR_POSTDT                                              ;DTBB1
public  VIOWRTNATTR
public  VIOWRTNATTR_POSTDT                                              ;DTBB1
public  VIOWRTNCELL
public  VIOWRTNCELL_POSTDT                                              ;DTBB1
public  VIOWRTCHARSTR
public  VIOWRTCHARSTR_POSTDT                                            ;DTBB1
public  VIOWRTCHARSTRATT
public  VIOWRTCHARSTRATT_POSTDT                                         ;DTBB1
public  VIOWRTCELLSTR
public  VIOWRTCELLSTR_POSTDT                                            ;DTBB1
public  VIOWRTTTY
public  VIOWRTTTY_POSTDT                                                ;DTBB1
public  VIOSCROLLUP
public  VIOSCROLLUP_POSTDT                                              ;DTBB1
public  VIOSCROLLDN
public  VIOSCROLLDN_POSTDT                                              ;DTBB1
public  VIOSCROLLLF
public  VIOSCROLLLF_POSTDT                                              ;DTBB1
public  VIOSCROLLRT
public  VIOSCROLLRT_POSTDT                                              ;DTBB1
public  VIOSETANSI
public  VIOSETANSI_POSTDT                                               ;DTBB1
public  VIOGETANSI
public  VIOGETANSI_POSTDT                                               ;DTBB1
public  VIOPRTSC
public  VIOPRTSC_POSTDT                                                 ;DTBB1
public  VIOSCRLOCK
public  VIOSCRLOCK_POSTDT                                               ;DTBB1
public  VIOSCRUNLOCK
public  VIOSCRUNLOCK_POSTDT                                             ;DTBB1
public  VIOSAVREDRAWWAIT
public  VIOSAVREDRAWWAIT_POSTDT                                         ;DTBB1
public  VIOSAVREDRAWUNDO
public  VIOSAVREDRAWUNDO_POSTDT                                         ;DTBB1
public  VIOPRTSCTOGGLE
public  VIOPRTSCTOGGLE_POSTDT                                           ;DTBB1
public  VIOMODEWAIT
public  VIOMODEWAIT_POSTDT                                              ;DTBB1
public  VIOMODEUNDO
public  VIOMODEUNDO_POSTDT                                              ;DTBB1
public  VIOGETFONT                                                      ;$B5I
public  VIOGETFONT_POSTDT                                               ;DTBB1
public  VIOGETCONFIG                                                    ;$B5I
public  VIOGETCONFIG_POSTDT                                             ;DTBB1
public  VIOGETCP                                                        ;@@1
public  VIOGETCP_POSTDT                                                 ;DTBB1
public  VIOSETCP                                                        ;@@1
public  VIOSETCP_POSTDT                                                 ;DTBB1
public  VIOSETFONT                                                      ;@@1
public  VIOSETFONT_POSTDT                                               ;DTBB1
public  VIOGETSTATE                                                     ;@@1
public  VIOGETSTATE_POSTDT                                              ;DTBB1
public  VIOSETSTATE                                                     ;@@1
public  VIOSETSTATE_POSTDT                                              ;DTBB1
public  VIOCHECKCHARTYPE
public  XVIOCHECKCHARTYPE
public  XVIOCREATECA
public  XVIOGETCASTATE
public  XVIOSETCASTATE
public  XVIODESTROYCA

instance segment byte public 'data'     USE16                           ;D549
instance ends

common segment byte public 'far_data'   USE16                      ;D549;@T52
common ends

cseg    segment byte public 'code'      USE16                           ;D549
        assume  cs:cseg,ds:instance,es:common,ss:nothing
        page

        SUBTTL VIOXXX - VIOFUNCTION CALL ENTRY POINTS
        page
;/*********************** START OF SPECIFICATIONS ***********************/
;/* SUBROUTINE NAMES:  VIOxxx                                           */
;/*                                                                     */
;/* DESCRIPTIVE NAMES:  VIO function call entry points.                 */
;/*                                                                     */
;/* FUNCTIONS:  Place the VIO function code on stack and CALL the       */
;/*             common router subroutine VIOROUT.                       */
;/*                                                                     */
;/* NOTES:  These external entry points are used by all video subsystems*/
;/*         The first time a process makes a VIO function               */
;/*         call, the VioAttach will be called.  VioAttach will call    */
;/*         DOSGETPROCADDR to get ptrs to the Base Video Subsystem      */
;/*         for the calling process.  The VIOROUT VIOxxx entry points   */
;/*         define the number of stack parameters for each VIOxxx       */
;/*         function, but the current video subsystem itself            */
;/*         defines the meanings of these parameters.                   */
;/*         parameters.                                                 */
;/*                                                                     */
;/* ENTRY POINTS:  VIOxxx                                               */
;/*     LINKAGES:  FAR CALL's (external API's)                          */
;/*                                                                     */
;/* INPUT:  Number of stack parms required is defined by the number of  */
;/*         words popped from stack when returning to the caller.  For  */
;/*         the meaning of the stack parms for each VIOxxx function,    */
;/*         see the Base Video Subsystem's corresponding BVSxxx         */
;/*         function input description.                                 */
;/*                                                                     */
;/* EXIT-NORMAL:  AX = 0                                                */
;/*                                                                     */
;/* EXIT-ERROR:  AX = error code set by VIOROUT                         */
;/*                                                                     */
;/* EFFECTS:  None.                                                     */
;/*                                                                     */
;/* INTERNAL REFERENCES:  None.                                         */
;/*            ROUTINES:  VIOROUT - Route the VIO function call to the  */
;/*                             current PID's BVSMAIN entry point as    */
;/*                             recorded in the instance data fields    */
;/*                             BVS_SEL and BVS_OFF.                    */
;/*                                                                     */
;/* EXTERNAL REFERENCES:  None.                                         */
;/*            ROUTINES:  None.                                         */
;/*********************** END OF SPECIFICATIONS *************************/

VIOGETPHYSBUF proc far
   mov  ax,bit_getphysbuf       ;function maskee                        ;1.2
   push fc_getphysbuf           ;VIO function number
   call viorout
VIOGETPHYSBUF_POSTDT label far                                          ;DTBB1
   ret  6                       ;return and pop parameters
VIOGETPHYSBUF endp

VIOGETBUF proc far
   mov  ax,bit_getbuf           ;function maskee                        ;1.2
   push fc_getbuf               ;VIO function number
   call viorout
VIOGETBUF_POSTDT label far                                              ;DTBB1
   ret  10                      ;return and pop parameters
VIOGETBUF endp

VIOSHOWBUF proc far
   mov  ax,bit_showbuf          ;function maskee                        ;1.2
   push fc_showbuf              ;VIO function number
   call viorout
;/********************************************************************/ ;@B44
;/*     Translate error return code to api specific return code      */ ;@B44
;/********************************************************************/ ;@B44
   .if <ax eq ERROR_VIO_ROW> or                                         ;@B44
   .if <ax eq ERROR_VIO_COL>                                            ;@B44
        mov     ax,ERROR_VIO_INVALID_PARMS                              ;@B44
   .endif                                                               ;@B44
VIOSHOWBUF_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters
VIOSHOWBUF endp

VIOGETCURPOS proc far
   mov  ax,bit_getcurpos        ;function maskee                        ;1.2
   push fc_getcurpos            ;VIO function number
   call viorout
VIOGETCURPOS_POSTDT label far                                           ;DTBB1
   ret  10                      ;return and pop parameters
VIOGETCURPOS endp

VIOGETCURTYPE proc far
   mov  ax,bit_getcurtype       ;function maskee                        ;1.2
   push fc_getcurtype           ;VIO function number
   call viorout
VIOGETCURTYPE_POSTDT label far                                          ;DTBB1
   ret  6                       ;return and pop parameters
VIOGETCURTYPE endp

VIOGETMODE proc far
   mov  ax,bit_getmode          ;function maskee                        ;1.2
   push fc_getmode              ;VIO function number
   call viorout
VIOGETMODE_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters
VIOGETMODE endp

VIOSETCURPOS proc far
   mov  ax,bit_setcurpos        ;function maskee                        ;1.2
   push fc_setcurpos            ;VIO function number
   call viorout
VIOSETCURPOS_POSTDT label far                                           ;DTBB1
   ret  6                       ;return and pop parameters
VIOSETCURPOS endp

VIOSETCURTYPE proc far
   mov  ax,bit_setcurtype       ;function maskee                        ;1.2
   push fc_setcurtype           ;VIO function number
   call viorout
VIOSETCURTYPE_POSTDT label far                                          ;DTBB1
   ret  6                       ;return and pop parameters
VIOSETCURTYPE endp

VIOSETMODE proc far
   mov  ax,bit_setmode          ;function maskee                        ;1.2
   push fc_setmode              ;VIO function number
   call viorout
VIOSETMODE_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters
VIOSETMODE endp

VIOSETCP proc far                                                       ;$Z9I

   push es                      ;                                       ;Proto
   mov  ax,common               ;need to setup es again                 ;Proto
   mov  es,ax                                                           ;Proto
   .if <es:SYIsetmodefl e 1>                                            ;Proto
     pop  es                    ;restore es before call to viorout      ;Proto
     mov  ax,bit_setcp            ;function maskee                        ;1.2
     push fc_setcp                ;VIO function number                    ;$Z9I
     call viorout                                                         ;$Z9I

     .if <zero ax>                                  ;if codepage set ok   ;@B50

       push bp                                                            ;@B50f
       mov  bp,sp                                                         ;@B50f
       push ds                    ;save registers
       push gs                    ;                                       ;@T80
       push bx                    ;                                       ;@B50

       mov  bx,instance           ;DS <-- instance data selector          ;@B50
       mov  ds,bx                 ;                                       ;@B50

       lgs  bx,ds:SGCB            ;load gs:[bx] with SGCB ptr             ;@T80
       mov  gs:[bx].VIO_dbcsflag,ax ;cause next check_dbc to call DOSGETDBCSEV ;@T80
       mov  ax,[bp].scp_codepg                      ;set SGCB codepageid  ;@B50
       mov  gs:[bx].VIO_CodePageID,ax                                ;@B50,@T80
       xor  ax,ax                                                         ;@B50

       pop  bx                    ;                                       ;@B50
       pop  gs                    ;                                       ;@T80
       pop  ds                    ;
       pop  bp                                                            ;@B50f
     .endif                                                               ;@B50
   .else                                                                ;Proto
       pop  es                    ;restore es
       xor  ax,ax                 ;set zero return code for nop call    ;Proto
   .endif                                                               ;Proto
VIOSETCP_POSTDT label far                                               ;DTBB1
   ret  6                       ;return and pop parameters              ;$Z9I
VIOSETCP endp                                                           ;$Z9I

VIOREADCHARSTR proc far
   mov  ax,bit_readcharstr      ;function maskee                        ;1.2
   push fc_readcharstr          ;VIO function number
   call viorout
VIOREADCHARSTR_POSTDT label far                                         ;DTBB1
   ret  14                      ;return and pop parameters
VIOREADCHARSTR endp

VIOREADCELLSTR proc far
   mov  ax,bit_readcellstr      ;function maskee                        ;1.2
   push fc_readcellstr          ;VIO function number
   call viorout
VIOREADCELLSTR_POSTDT label far                                         ;DTBB1
   ret  14                      ;return and pop parameters
VIOREADCELLSTR endp

VIOWRTNCHAR proc far
   mov  ax,bit_wrtnchar         ;function maskee                        ;1.2
   push fc_wrtnchar             ;VIO function number
   call viorout
VIOWRTNCHAR_POSTDT label far                                            ;DTBB1
   ret  12                      ;return and pop parameters
VIOWRTNCHAR endp

VIOWRTNATTR proc far
   mov  ax,bit_wrtnattr         ;function maskee                        ;1.2
   push fc_wrtnattr             ;VIO function number
   call viorout
VIOWRTNATTR_POSTDT label far                                            ;DTBB1
   ret  12                      ;return and pop parameters
VIOWRTNATTR endp

VIOWRTNCELL proc far
   mov  ax,bit_wrtncell         ;function maskee                        ;1.2
   push fc_wrtncell             ;VIO function number
   call viorout
VIOWRTNCELL_POSTDT label far                                            ;DTBB1
   ret  12                      ;return and pop parameters
VIOWRTNCELL endp

VIOWRTCHARSTR proc far
   mov  ax,bit_wrtcharstr       ;function maskee                        ;1.2
   push fc_wrtcharstr           ;VIO function number
   call viorout
VIOWRTCHARSTR_POSTDT label far                                          ;DTBB1
   ret  12                      ;return and pop parameters
VIOWRTCHARSTR endp

VIOWRTCHARSTRATT proc far
   mov  ax,bit_wrtcharstratt    ;function maskee                        ;1.2
   push fc_wrtcharstratt        ;VIO function number
   call viorout
VIOWRTCHARSTRATT_POSTDT label far                                       ;DTBB1
   ret  16                      ;return and pop parameters
VIOWRTCHARSTRATT endp

VIOWRTCELLSTR proc far
   mov  ax,bit_wrtcellstr       ;function maskee                        ;1.2
   push fc_wrtcellstr           ;VIO function number
   call viorout
VIOWRTCELLSTR_POSTDT label far                                          ;DTBB1
   ret  12                      ;return and pop parameters
VIOWRTCELLSTR endp

VIOWRTTTY proc far
   enter 12,0

   push  ds                                                        ;Proto
   mov   ax,instance            ;DS <-- instance data seg. selector;Proto
   mov   ds,ax                                                     ;Proto

   .if <ds:currSG e 0>
      push es                                                      ;Proto
      mov  ax,common       ;need to setup es again                 ;Proto
      mov  es,ax                                                   ;Proto
     .if <es:SYIsetmodefl e -1>                                    ;Proto
        mov  es:SYIsetmodefl,1                                     ;Proto
        xor  ax,ax                                                 ;Proto
        push es              ;data area for mode data struc.       ;Proto
        push offset SYIsetmode                                     ;Proto
        push ax              ;VIOhandle                            ;Proto
        call VIOSETMODE                                            ;Proto
        push 2               ;get curr session's process codepage  ;Proto
        push es              ;                                     ;Proto
        push offset SYICP    ;                                     ;Proto
        push es              ;                                     ;Proto
        push offset SYICPlength                                    ;Proto
        call DOSGETCP        ;                                     ;Proto
        push 0               ;set current session's video codepage ;Proto
        push es:SYICP        ;                                     ;Proto
        push 0               ;                                     ;Proto
        call VIOSETCP        ;                                     ;Proto
     .endif                                                        ;Proto
      pop  es                                                      ;Proto
   .endif                                                          ;Proto
   pop   ds

   .if <[bp].tty_len a 82> near ;if string size above 82 bytes
     mov  ax,[bp].tty_sel       ;set up "working" stack frame
     mov  [bp]-ptty_sel,ax      ;
     mov  ax,[bp].tty_off       ;
     mov  [bp]-ptty_off,ax      ;
     mov  ax,[bp].tty_len       ;
     mov  [bp]-ptty_len,ax      ;
     mov  ax,[bp].tty_hnd       ;
     mov  [bp]-ptty_hnd,ax      ;

     .while <[bp].tty_len a 82> near    ;while string size above 82 bytes
       push bx                  ;save BX
       push cx                  ;save CX
       mov  cx,81
       mov  bx,0001H
       mov  ah,0FFH

       .while <ah eq 0FFH> and  ;do until (non-"DBCS prefix" found)
       .while <cx ge 0>         ;      or (beginning of string)
         push [bp].tty_sel      ;string selector
         mov  ax,[bp]-ptty_off  ;string offset
         add  ax,cx             ;
         push ax                ;
         call check_dbc         ;check for double-byte character
                                ; AH = 0FFH if DBCS prefix found
         xor  bx,0001H          ;toggle low bit of BL
         dec  cx                ;
       .endwhile

       .if <bx eq 0> or
       .if <cx eq 0FFFFH>
         pop  cx                ;restore CX
         pop  bx                ;restore BX
         mov  [bp]-ptty_len,82  ;set string size to 82

         mov  ax,bit_wrttty     ;function maskee                        ;1.2
         push fc_wrttty         ;VIO function number
         call viorout

         sub  [bp].tty_len,82   ;keep track of num of remaining chars
         add  [bp].tty_off,82   ;true offset bumped 82 chars
         add  [bp]-ptty_off,82  ;"working" offset bumped 82 chars
       .else
         pop  cx                ;restore CX
         pop  bx                ;restore BX
         mov  [bp]-ptty_len,81  ;set string size to 81

         mov  ax,bit_wrttty     ;function maskee                        ;1.2
         push fc_wrttty         ;VIO function number
         call viorout

         sub  [bp].tty_len,81   ;keep track of num of remaining chars
         add  [bp].tty_off,81   ;true offset bumped 81 chars
         add  [bp]-ptty_off,81  ;"working" offset bumped 81 chars
       .endif

     .endwhile

   .endif

   leave
   mov  ax,bit_wrttty           ;function maskee                        ;1.2
   push fc_wrttty               ;VIO function number
   call viorout
VIOWRTTTY_POSTDT label far                                              ;DTBB1
   ret  8                       ;return and pop parameters
VIOWRTTTY endp

VIOSCROLLUP proc far
   mov  ax,bit_scrollup         ;function maskee                        ;1.2
   push fc_scrollup             ;VIO function number
   call viorout
VIOSCROLLUP_POSTDT label far                                            ;DTBB1
   ret  16                      ;return and pop parameters
VIOSCROLLUP endp

VIOSCROLLDN proc far
   mov  ax,bit_scrolldn         ;function maskee                        ;1.2
   push fc_scrolldn             ;VIO function number
   call viorout
VIOSCROLLDN_POSTDT label far                                            ;DTBB1
   ret  16                      ;return and pop parameters
VIOSCROLLDN endp

VIOSCROLLLF proc far
   mov  ax,bit_scrolllf         ;function maskee                        ;1.2
   push fc_scrolllf             ;VIO function number
   call viorout
VIOSCROLLLF_POSTDT label far                                            ;DTBB1
   ret  16                      ;return and pop parameters
VIOSCROLLLF endp

VIOSCROLLRT proc far
   mov  ax,bit_scrollrt         ;function maskee                        ;1.2
   push fc_scrollrt             ;VIO function number
   call viorout
VIOSCROLLRT_POSTDT label far                                            ;DTBB1
   ret  16                      ;return and pop parameters
VIOSCROLLRT endp

VIOSETANSI proc far
   mov  ax,bit_setansi          ;function maskee                        ;1.2
   push fc_setansi              ;VIO function number
   call viorout
VIOSETANSI_POSTDT label far                                             ;DTBB1
   ret  4                       ;return and pop parameters
VIOSETANSI endp

VIOGETANSI proc far
   mov  ax,bit_getansi          ;function maskee                        ;1.2
   push fc_getansi              ;VIO function number
   call viorout
VIOGETANSI_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters
VIOGETANSI endp

VIOPRTSC proc far
   mov  ax,bit_prtsc            ;function maskee                        ;1.2
   push fc_prtsc                ;VIO function number
   call viorout
VIOPRTSC_POSTDT label far                                               ;DTBB1
   ret  2                       ;return and pop parameters
VIOPRTSC endp

VIOSCRLOCK proc far
   mov  ax,bit_scrlock          ;function maskee                        ;1.2
   push fc_scrlock              ;VIO function number
   call viorout

   push  ax                     ;save return code from viorout          ;@A0
   push  ds                     ;                                       ;@A0
   push  es                     ;                                       ;@A0

   mov   ax,instance            ;DS <-- INSTANCE data segment           ;@A0
   mov   ds,ax                  ;                                       ;@A0
   mov   es,ds:gdtinfo          ;ES <-- GDT infoseg                     ;@A0

   mov   al,es:[SIS_CurScrnGrp] ;                                       ;@A0
   cbw                          ;                                       ;@T2

   .if<ax eq ds:currSG>                                                 ;@A0
     mov   ax,common                                                    ;@A0
     mov   es,ax                                                        ;@A0
     inc   es:dirty                                                 ;@T2;@A0
   .endif                                                               ;@A0

   pop   es                     ;restore registers                      ;@A0
   pop   ds                     ;                                       ;@A0
   pop   ax                     ;                                       ;@A0
VIOSCRLOCK_POSTDT label far                                             ;DTBB1

   ret  8                       ;return and pop parameters
VIOSCRLOCK endp

VIOSCRUNLOCK proc far
   mov  ax,bit_scrunlock        ;function maskee                        ;1.2
   push fc_scrunlock            ;VIO function number
   call viorout
VIOSCRUNLOCK_POSTDT label far                                           ;DTBB1
   ret  2                       ;return and pop parameters
VIOSCRUNLOCK endp

cseg ends                                                               ;MDLL



CTEXT_TUNE4  segment byte public 'code'      USE16                      ;MDLL
        assume  cs:CTEXT_TUNE4,ds:instance,es:common,ss:nothing         ;MDLL

VIOSAVREDRAWWAIT proc far
   push es                              ;save ES                        ;@CJ42
   mov  ax,common                       ;ES <-- common data selector    ;@CJ42
   mov  es,ax                                                           ;@CJ42

   .if <es:shellVSRW_done eq 0>         ;if shell not called this yet   ;@CJ42
     push ds                            ;save DS                        ;@CJ42
     mov  ax,instance                   ;DS <-- instance data selector  ;@CJ42
     mov  ds,ax                                                         ;@CJ42
     mov  ax,ds:currPID                 ;get current PID                ;@CJ42

     .if <ax eq es:SHELLPID>            ;if shell did this call   ;@CJ42,@T14
       mov  es:shellVSRW_done,1         ;set flag so VioPopups can be   ;@CJ42
     .endif                             ;allowed                        ;@CJ42
     pop  ds                                                            ;@CJ42
   .endif                                                               ;@CJ42
   pop  es                                                              ;@CJ42

   mov  ax,bit_savredrawwait    ;function maskee                        ;1.2
   push fc_savredrawwait        ;VIO function number
   call viorout

   .if <zero ax>                                                        ;@T2
     push ds            ;save registers
     push es            ;
     push gs            ;                                               ;@T80
     push bx            ;

     mov  ax,instance   ;address data segments
     mov  ds,ax         ;

     mov  es,ds:ldtinfo         ;ES <-- Local InfoSeg                   ;@T2
     mov  ax,es:[LIS_CurThrdID] ;AX <-- current thread ID               ;@T2

     lgs  bx,ds:SGCB            ;load gs:[bx] with SGCB ptr             ;@T80

     mov  gs:[bx].VIO_srwTID,ax ;SGCB.srwTID <-- thread ID              ;@T80

     mov  ax,ds:currPID         ;SGDATA[currSG].srwPID <-- currPID
     mov  gs:[bx].VIO_srwPID,ax ;SGCB.srwTID <-- thread ID              ;@T80

     pop  bx            ;
     pop  gs            ;                                               ;@T80
     pop  es            ;
     pop  ds            ;
     xor  ax,ax
   .endif

VIOSAVREDRAWWAIT_POSTDT label far                                       ;DTBB1
   ret  8                       ;return and pop parameters
VIOSAVREDRAWWAIT endp

CTEXT_TUNE4      ends                                                   ;MDLL




cseg    segment byte public 'code'      USE16                           ;MDLL
        assume  cs:cseg,ds:instance,es:common,ss:nothing                ;MDLL

VIOSAVREDRAWUNDO proc far
   mov  ax,bit_savredrawundo    ;function maskee                        ;1.2
   push fc_savredrawundo        ;VIO function number
   call viorout

   .if <zero ax>                                                        ;@T2
     push ds            ;save registers
     push es            ;
     push gs            ;                                               ;@T80
     push bx            ;

     mov  ax,instance   ;address data segments
     mov  ds,ax         ;

     lgs  bx,ds:SGCB            ;load gs:[bx] with SGCB ptr             ;@T80

     sub  ax,ax                                                         ;@T2
     mov  gs:[bx].VIO_srwTID,ax ;reset SGDATA[currSG].srwTID        ;@T2,@T80
     mov  gs:[bx].VIO_srwPID,ax ;reset SGDATA[currSG].srwPID        ;@T2,@T80

     pop  bx            ;
     pop  gs            ;                                               ;@T80
     pop  es            ;
     pop  ds            ;
   .endif

VIOSAVREDRAWUNDO_POSTDT label far                                       ;DTBB1
   ret  6                       ;return and pop parameters
VIOSAVREDRAWUNDO endp

VIOPRTSCTOGGLE proc far
   mov  ax,bit_prtsctoggle      ;function maskee                        ;1.2
   push fc_prtsctoggle          ;VIO function number
   call viorout
VIOPRTSCTOGGLE_POSTDT label far                                         ;DTBB1
   ret  2                       ;return and pop parameters
VIOPRTSCTOGGLE endp

VIOMODEWAIT proc far
   mov  ax,bit_modewait         ;function maskee                        ;1.2
   push fc_modewait             ;VIO function number
   call viorout

   .if <zero ax>                                                        ;@T2
     push ds            ;save registers
     push es            ;
     push gs            ;                                               ;@T80
     push bx            ;

     mov  ax,instance   ;address data segments
     mov  ds,ax         ;

     lgs  bx,ds:SGCB            ;load gs:[bx] with SGCB ptr             ;@T80

     mov  es,ds:ldtinfo         ;ES <-- Local InfoSeg                   ;@T2
     mov  ax,es:[LIS_CurThrdID] ;AX <-- current thread ID               ;@T2

     mov  gs:[bx].VIO_smwTID,ax ;SGCB.smwTID <-- thread ID              ;@T80

     mov  ax,ds:currPID         ;SGDATA[currSG].smwPID <-- currPID
     mov  gs:[bx].VIO_smwPID,ax ;                                       ;@T80

     pop  bx            ;
     pop  gs            ;                                               ;@T80
     pop  es            ;
     pop  ds            ;
     xor  ax,ax
   .endif

VIOMODEWAIT_POSTDT label far                                            ;DTBB1
   ret  8                       ;return and pop parameters
VIOMODEWAIT endp


VIOMODEUNDO proc far
   mov  ax,bit_modeundo         ;function maskee                        ;1.2
   push fc_modeundo             ;VIO function number
   call viorout

   .if <zero ax>                                                        ;@T2
     push ds            ;save registers
     push es            ;
     push gs            ;                                               ;@T80
     push bx            ;

     mov  ax,instance   ;address data segments
     mov  ds,ax         ;

     lgs  bx,ds:SGCB            ;load gs:[bx] with SGCB ptr             ;@T80

     sub  ax,ax
     mov  gs:[bx].VIO_smwTID,ax ;reset SGCB.smwTID                      ;@T80
     mov  gs:[bx].VIO_smwPID,ax ;reset SGCB.smwPID                      ;@T80

     pop  bx            ;
     pop  gs            ;                                               ;@T80
     pop  es            ;
     pop  ds
   .endif

VIOMODEUNDO_POSTDT label far                                            ;DTBB1
   ret  6                       ;return and pop parameters
VIOMODEUNDO endp


VIOGETFONT proc far                                                     ;$B5I
   mov  ax,bit_getfont          ;function maskee                        ;1.2
   push fc_getfont              ;VIO function number                    ;$B5I
   call viorout                                                         ;$B5I
VIOGETFONT_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters              ;$Z8C
VIOGETFONT endp                                                         ;$B5I


VIOGETCONFIG proc far                                                   ;$Z9I
   mov  ax,bit_getconfig        ;function maskee                        ;1.2
   push fc_getconfig            ;VIO function number                    ;$Z9I
   call viorout                                                         ;$Z9I

IFDEF MMIOPH                                                            ;DTBB1f

   push es                      ;save registers                         ;$Z8I
   push ds                      ;                                       ;$Z8I
   pushf                        ;                                       ;$Z8I
   push ax                      ;                                       ;$Z8I

   mov  ax,instance             ;DS <--  INSTANCE data selector         ;$Z8I
   mov  ds,ax                   ;                                       ;$Z8I

   mov  es,ds:gdtinfo                           ;ES <-- global info sel.;DTBB1f
   mov  al,es:[SIS_MEC_TABLE].SIS_VIOMEC        ;AL <-- byte w/VIO MEC  ;DTBB1f
   test al,traceonoffmask                       ;0=OFF, non-0=ON        ;DTBB1f

   .if <nz>                     ;is Performance Trace enabled?          ;DTBB1f
     mov   al,byte ptr es:[SIS_MEC_TABLE]       ;AL <-- MMIO MEC byte   ;MMIO
     test  al,40h                               ;0=OFF, non-0=ON        ;@T3

     .if <nz> near      ;is Performance Trace enabled?                  ;MMIO
       push di                                                          ;MMIO
       mov  di,fc_getconfig                                             ;MMIO

       call MMIO_post                                                   ;MMIO
       pop  di                                                          ;MMIO
     .endif                                                             ;MMIO
   .endif                                                               ;DTBB1f

   pop  ax                      ;restore registers                      ;$Z8I
   popf                         ;                                       ;$Z8I
   pop  ds                      ;                                       ;$Z8I
   pop  es                      ;                                       ;$Z8I
ENDIF

VIOGETCONFIG_POSTDT label far                                           ;DTBB1
   ret  8                       ;return and pop parameters              ;$Z9I
VIOGETCONFIG endp                                                       ;$Z9I


VIOGETCP proc far                                                       ;$Z9I
   mov  ax,bit_getcp            ;function maskee                        ;1.2
   push fc_getcp                ;VIO function number                    ;$Z9I
   call viorout                                                         ;$Z9I
VIOGETCP_POSTDT label far                                               ;DTBB1
   ret  8                       ;return and pop parameters              ;$Z9I
VIOGETCP endp                                                           ;$Z9I


VIOSETFONT proc far                                                     ;$Z9I
   mov  ax,bit_setfont          ;function maskee                        ;1.2
   push fc_setfont              ;VIO function number                    ;$Z9I
   call viorout                                                         ;$Z9I
VIOSETFONT_POSTDT label far                                             ;DTBB1
   ret  6                       ;return and pop parameters              ;$Z9I
VIOSETFONT endp                                                         ;$Z9I

VIOGETSTATE proc far                                                    ;$Z9I
   mov  ax,bit_getstate         ;function maskee                        ;1.2
   push bp                                                              ;D811
   push es                                                              ;D811
   push di                                                              ;D811
   mov  bp,sp                                                           ;D811
   les  di, dword ptr [bp]+0Ch  ;get type paramter                      ;D811
   cmp  es:[di]+2, OEMFUNCTION  ;look for OEM defined function          ;D811
   jb   gstate1                                                         ;D811
   mov  ax,bit_getstateOEM      ;function mask for OEM defined Get State;D811
gstate1:                                                                ;D811
   pop  di                                                              ;D811
   pop  es                                                              ;D811
   pop  bp                                                              ;D811
   push fc_getstate             ;VIO function number                    ;$Z9I
   call viorout                                                         ;$Z9I
VIOGETSTATE_POSTDT label far                                            ;DTBB1
   ret  6                       ;return and pop parameters              ;$Z9I
VIOGETSTATE endp                                                        ;$Z9I

VIOSETSTATE proc far                                                    ;$Z9I
   mov  ax,bit_setstate         ;function maskee                        ;1.2
   push bp                                                              ;D811
   push es                                                              ;D811
   push di                                                              ;D811
   mov  bp,sp                                                           ;D811
   les  di, dword ptr [bp]+0Ch  ;get type paramter                      ;D811
   cmp  es:[di]+2, OEMFUNCTION  ;look for OEM defined function          ;D811
   jb   sstate1                                                         ;D811
   mov  ax,bit_setstateOEM      ;function mask for OEM defined Get State;D811
sstate1:                                                                ;D811
   pop  di                                                              ;D811
   pop  es                                                              ;D811
   pop  bp                                                              ;D811
   push fc_setstate             ;VIO function number                    ;$Z9I
   call viorout                                                         ;$Z9I
VIOSETSTATE_POSTDT label far                                            ;DTBB1
   ret  6                       ;return and pop parameters              ;$Z9I
VIOSETSTATE endp                                                        ;$Z9I

XVIOCHECKCHARTYPE proc far
VIOCHECKCHARTYPE label far
   mov  ax,bit_checkchartype    ;function maskee
   push fc_checkchartype        ;VIO function number
   call viorout
   ret  10                      ;return and pop parameters
XVIOCHECKCHARTYPE endp


XVIOCREATECA proc far
   mov  ax,bit_createca         ;function maskee
   push fc_createca             ;VIO function number
   call viorout
   ret  10                      ;return and pop parameters
XVIOCREATECA endp


XVIOGETCASTATE proc far
   mov  ax,bit_getcastate       ;function maskee
   push fc_getcastate           ;VIO function number
   call viorout
   ret  8                       ;return and pop parameters
XVIOGETCASTATE endp


XVIOSETCASTATE proc far
   mov  ax,bit_setcastate       ;function maskee
   push fc_setcastate           ;VIO function number
   call viorout
   ret  6                       ;return and pop parameters
XVIOSETCASTATE endp


XVIODESTROYCA proc far
   mov  ax,bit_destroyca        ;function maskee
   push fc_destroyca            ;VIO function number
   call viorout
   ret  4                       ;return and pop parameters
XVIODESTROYCA endp

cseg ends
     end
