home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / WDHMAIN.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  57KB  |  1,230 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.         PAGE    58,132
  13.         TITLE   WDHMAIN.Asm -- Windowable Device Handler
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = WDHMAIN.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = BVS Device Handler for Windowable Sessions
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE
  25. ;*
  26. ;* DESCRIPTION  This module contains the equivalent of the OS/2 1.1
  27. ;*              hooks for Windowable and Advanced VIO.
  28. ;*
  29. ;* FUNCTIONS    DevEnable, RetConfigInfo, InitEnv, WDHError
  30. ;*
  31. ;* NOTES        NONE
  32. ;*
  33. ;* STRUCTURES   NONE
  34. ;*
  35. ;* EXTERNAL REFERENCES
  36. ;*
  37. ;*              NONE
  38. ;*
  39. ;* EXTERNAL FUNCTIONS
  40. ;*
  41. ;*              NONE
  42. ;*
  43. ;* CHANGE ACTIVIY =
  44. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  45. ;*   --------  ---------- -----   --------------------------------------
  46. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  47. ;*   12/11/88  @T2        P3108   TPL, GreInitialize is necessary in DevEnable
  48. ;*   12/11/88  @T2                for VIO,
  49. ;*   12/19/88  @T7        P3258   TPL, Deadlock when MOUOPEN reenters VIOCALLS
  50. ;*   12/19/88  @T7                under DosStartSession when VIO or PM app is
  51. ;*   12/19/88  @T7                in a popup,
  52. ;*   02/17/89  @T17       SL01217 TPL, Save and restore AX around UpdateMode,
  53. ;*   02/21/89  @@A        B700261 STJ, Emulate GRows as 16*TRows,
  54. ;*   03/16/89  @T19       P6741   TPL, Avoid loading AVIO at boot time,
  55. ;*   03/22/89  @T22       B700622 TPL, Return codepage of 0 if DEVINFO is wrong
  56. ;*   03/25/89  @P1        D132     PL, DCR 132 changes
  57. ;*   04/10/89  D198               STJ, Install BvsPrtSc and BvsWrtTTY as
  58. ;*   04/10/89  D198               default VDH routines
  59. ;*   04/04/89  @T25       B700??? TPL, Sizzle work,
  60. ;*   04/20/89  @C16       B701177 CJJ, Stack parameters changed, PTR
  61. ;*   04/25/89  D261               STJ, Selector list moved to BVSGSEG
  62. ;*   05/09/89  @BB7       B702184 WKB, Restructure config data structure,
  63. ;*   05/11/89  @S10       B701174 STJ, Retain separate ENVB/LVB for each config
  64. ;*   05/18/89  @C22       HZ00183 CJJ, Update scrollable region in UpdateMode,
  65. ;*   05/30/89  @S13       B702717 STJ, Increase the ENVB size for AVio sessions
  66. ;*   07/19/89  @S18       B704913 STJ, Return ShieldInit return code,
  67. ;*   08/07/89  @C30       B706051 CJJ, Call DosGetCP to get prepared codepages
  68. ;*   08/18/89  @S25       B706860 STJ, Use 1.0 length as default for GetXXXX
  69. ;*   08/18/89  @S25               calls
  70. ;*   10/12/89  @B25       HM00772 WKB, Clear selector table data on DestroyPS
  71. ;*   10/24/89  @S38       B786295 STJ, Use 8-pel default size for non-25-line
  72. ;*   10/24/89  @S38       B786295 modes,
  73. ;*   11/02/89  @D549      D549    CJJ, Seltable changes due to rangeless sessions
  74. ;*   11/30/89  D811       D811    MS,  DCR 811
  75. ;*   01/22/90  @T52       D704    TPL, DCR 704 work
  76. ;*   03/16/90  @B48       B788584 WKB, Clear ax after use,
  77. ;*   07/06/90  @T71       B714347 TPL, Allow Shell to make AVIO calls, Hursley
  78. ;*   07/06/90  @T71       B714347 DCR 25177,
  79. ;*   09/14/90  AR07027    AR07027 WKB, Update PS attrbytes for avio
  80. ;*   09/14/90  AR07027            accordingly
  81. ;*   10/23/90  AR07042    AR07042 WKB, Handle WinInit and Gre errors,
  82. ;*   04/11/91  D1348      D1348   NAKADA, Enable DBCS support in Vio-Window
  83. ;*   06/05/91  @S38f      SM03642 WKB, Use 8-pel default size for > 25-line
  84. ;*   06/05/91  @S38f              modes
  85. ;*   02/06/92  @T80       B732479 TPL, Don't use the reserved register FS,
  86. ;*   02/21/92  @T83       AR12264 TPL, Avoid reallocation of the Env buffer
  87. ;*   02/21/92  @T83               for AVIO,
  88. ;****************************************************************************/
  89.  
  90. INCL_WINPROGRAMLIST  equ   1    ;needed for pmshl.inc defines      ;@D549
  91. SESMGR               equ   1    ;needed for pmshl.inc defines      ;@D549
  92.  
  93.         include pmshl.inc               ;PM Shell equates for PROG_WIN  ;@D549
  94.         include pmwinx.inc
  95.         include pmaviop.inc
  96.         include wdhequ.inc
  97.  
  98.         include bvscb.inc               ;BVS Control Blocks
  99.         include bvsparms.inc            ;BVS Parameter Equates
  100.         include error2.inc              ;CP/DOS Error Codes
  101.         include infoseg.inc             ;DOS Info Seg
  102.         .xlist
  103.         include struc.inc               ;Structured Macros
  104.         .list
  105.  
  106.         .386p                   ;@D549
  107.  
  108.         extrn   BUFFERUPDATE:FAR        ;Text Buffer Update
  109.         extrn   GetCursorInfo:FAR       ;Get Cursor Info
  110.         extrn   SetCursorInfo:FAR       ;Set Cursor Info
  111.         extrn   GetMode:FAR             ;Get Mode
  112.         extrn   SetMode:FAR             ;Set Mode
  113.         extrn   GetVarInfo:FAR          ;Get Variable Info
  114.         extrn   SetVarInfo:FAR          ;Set Variable Info
  115.         extrn   GetDBCSInfo:FAR         ;Get DBCS Display Info          ;@P1
  116.         extrn   GetLVBInfo:FAR          ;Get LVB size Info              ;@P1
  117.         extrn   GetState:FAR            ;Get video date                 ;D811
  118.         extrn   SetState:FAR            ;Set video state                ;D811
  119.  
  120.         extrn   DOSGETINFOSEG:FAR       ;Get InfoSeg selectors
  121.         extrn   DOSGETCP:FAR            ;Dos Get CodePage
  122.  
  123. IFDEF D1348 ;get DBCS environment vectors.
  124.         extrn   DOSGETDBCSEV:FAR        ; Get DBCS environment vectors
  125. ENDIF ;D1348
  126.  
  127. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  128.         extrn   BvscbSel:WORD                                           ;;EPOCH ;; added for J-FUNC
  129. ;@an07  extrn   pBvscbSels:DWORD                                        ;;EPOCH ;; added for J-FUNC
  130. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  131. IFDEF DBCSENBL ; prepare the 2nd LVB for DBCS flag                      ;;DBCS  ;; added for J-FUNC
  132.         extrn   DOSALLOCSEG:FAR         ; Dos Allocate memory segment   ;;DBCS  ;; added for J-FUNC
  133.         extrn   DOSFREESEG:FAR          ; Dos Free memory segment       ;;DBCS  ;; added for J-FUNC
  134.         extrn   DOSGETSEG:FAR                                           ;;DBCS  ;; added for J-FUNC
  135. ENDIF ; DBCSENBL                                                        ;;DBCS  ;; added for J-FUNC
  136.         extrn   MOUGETEVENTMASK:FAR
  137.         extrn   DOSOPEN:FAR             ;  @T7
  138.         extrn   DOSCLOSE:FAR            ;  @T7
  139.         extrn   DOSREALLOCSEG:FAR       ;@S13
  140.  
  141.         extrn   QueryConsole:NEAR
  142.         extrn   ShieldInit:NEAR
  143.         extrn   ShieldTerm:NEAR
  144.         extrn   SecureSema4:NEAR
  145.         extrn   ReleaseSema4:NEAR
  146.  
  147.         extrn   AVIOSUBS:FAR                                            ;@T52
  148.         extrn   WININITIALIZE:FAR                                       ;@T52
  149.         extrn   GREINITIALIZE:FAR                                       ;@T52
  150.  
  151.         extrn   BVHINSTANCE:WORD                                        ;@T52
  152.         extrn   BVSGLOBAL:WORD                                          ;@T52
  153.  
  154. WDHGSEG SEGMENT WORD PUBLIC 'DATA' USE16 ;Global data segment for WDH   ;@T71
  155.  
  156. WDHGLOBAL       label   far                                             ;@T52
  157.         PUBLIC  WDHGLOBAL                                               ;@T52
  158. wdh_flags       dw      0               ;Global flags                   ;@T52
  159.         PUBLIC  wdh_flags                                               ;@T52
  160. wdh_LISsel      dw      0               ;Local Info Segment             ;@T52
  161.         PUBLIC  wdh_LISsel                                              ;@T52
  162. wdh_SISsel      dw      0               ;System Info Segment            ;@T52
  163.         PUBLIC  wdh_SISsel                                              ;@T52
  164. wdh_LastFS      dw      0               ;Last Full-screen Session   ;@T2;@T52
  165.         PUBLIC  wdh_LastFS                                              ;@T52
  166. wdh_keybufsize  dw      0               ;Keyboard Buffer Size           ;@T52
  167.         PUBLIC  wdh_keybufsize                                          ;@T52
  168. wdh_moubufsize  dw      0               ;Mouse Buffer Size              ;@T52
  169.         PUBLIC  wdh_moubufsize                                          ;@T52
  170. wdh_mouevntmask dw      0               ;Mouse Event Mask               ;@T52
  171.         PUBLIC  wdh_mouevntmask                                         ;@T52
  172. Mouse_Name      db      'MOUSE$',0,0    ;                 ;@T25;@T7;@T52;@T71
  173.         PUBLIC  Mouse_Name                                              ;@T52
  174. wdh_numcpids    dw      0               ;Number of prepared CPs     @C30;@T52
  175.         PUBLIC  wdh_numcpids                                            ;@T52
  176. wdh_cpidcurrnt  dw      0               ;current prepared codepage  @C30;@T52
  177.         PUBLIC  wdh_cpidcurrnt                                          ;@T52
  178. wdh_cpid1       dw      0               ;1st prepared codepage      @C30;@T52
  179.         PUBLIC  wdh_cpid1                                               ;@T52
  180. wdh_cpid2       dw      0               ;2nd prepared codepage      @C30;@T52
  181.         PUBLIC  wdh_cpid2                                               ;@T52
  182.  
  183. ProtoEnv wdhenvironment <>              ;Prototype Environment
  184.         PUBLIC  ProtoEnv                                                ;@T52
  185.  
  186. Config  configdata <,-1,-1,8000h,,,,size wdhenvironment,8000h,8000h,-8+size configdata,-4+size configdata,1,-1,1,-1> ;@BB7
  187.         PUBLIC  Config                                                  ;@T52
  188.  
  189. bvh_instance    dd      BVHINSTANCE                                     ;@T52
  190.         public  bvh_instance                                            ;@T52
  191. bvs_global      dd      BVSGLOBAL                                       ;@T52
  192.         public  bvs_global                                              ;@T52
  193.  
  194. ;/*
  195. ;** Table of addresses of WDH functio
  196. ;*/
  197.  
  198.         public  FnTable
  199. FnTable dd      BufferUpdate            ;Text Buffer Update
  200.         dd      InitEnv                 ;Initialize Environment
  201.         dd      WDHDummy                ;Save Environment
  202.         dd      WDHDummy                ;Restore Environment
  203.         dd      GetConfig               ;Return Config Info
  204.         dd      GetDBCSInfo             ;Get DBCS Display Info          ;@P1
  205.         dd      WDHError                ;Get Color Lookup Table
  206.         dd      WDHError                ;Set Color Lookup Table
  207.         dd      GetCursorInfo           ;Get Cursor Info
  208.         dd      SetCursorInfo           ;Set Cursor Info
  209.         dd      WDHError                ;Get Font
  210.         dd      WDHError                ;Set Font
  211.         dd      GetMode                 ;Get Mode
  212.         dd      SetMode                 ;Set Mode
  213.         dd      WDHError                ;Get Palette Registers
  214.         dd      WDHError                ;Set Palette Registers
  215.         dd      WDHError                ;Get Phys Buf
  216.         dd      WDHError                ;Free Phys Buf
  217.         dd      GetVarInfo              ;Get Variable Info
  218.         dd      SetVarInfo              ;Set Variable Info
  219.         dd      ExtVIO                  ;Extended VIO Calls
  220.         dd      0                       ;Print Screen                   ;D198
  221.         dd      0                       ;Write TTY                      ;D198
  222.         dd      GetLVBInfo              ;Get LVB Info Call              ;@P1
  223.         dd      GetState                ;Get video state                ;D811
  224.         dd      SetState                ;Set video state                ;D811
  225.  
  226. WDHGSEG ENDS
  227.  
  228.  
  229. R2CSEG  SEGMENT BYTE PUBLIC 'CODE' USE16                                ;@D549
  230.         ASSUME  CS:R2CSEG
  231.  
  232. ;/****************************************************************************
  233. ;*
  234. ;*  SUBROUTINE NAME: DevEnable
  235. ;*
  236. ;*  DESCRIPTIVE NAME: Initialize call vector table
  237. ;*
  238. ;*  FUNCTION: DevEnable is called via the Presentation Manager DDI
  239. ;*            interface.  The entry points of all VDH routines are
  240. ;*            appropriately entered into the call vector table.
  241. ;*            In addition, display adapter configuration is verified.
  242. ;*
  243. ;*  ENTRY POINT: DevEnable
  244. ;*    LINKAGE:   CALL FAR
  245. ;*
  246. ;*  INPUT: (Passed on stack)
  247. ;*             FAR * Parameter2  ( far pointer to parameter 2 packet )
  248. ;*                      FAR *Flags
  249. ;*                      FAR *CallVectorTable (BVS's call table)
  250. ;*             FAR * Parameter1  ( far pointer to parameter 1 packet )
  251. ;*                      ULONG EngineVersion ( Graphics engine ver. )
  252. ;*                      ULONG TableSize ( Length of call table )
  253. ;*             ULONG Subfunction ( Enable subfunction )
  254. ;*         (Referenced)
  255. ;*             VDHEntryPoint[] (global data - table of entry points )
  256. ;*             HugeShift (global data - huge shift value)
  257. ;*             hScreenDD (global data - screen device driver handle)
  258. ;*
  259. ;*  EXIT-NORMAL: AX = 0
  260. ;*               Entries in VDHEntryPoint table are copied to
  261. ;*                  CallVectorTable
  262. ;*
  263. ;*  EXIT-ERROR: AX = ERROR_VIO_BAD_ADAPTER or
  264. ;*                   DosGetHugeShift error or
  265. ;*                   DosOpen error
  266. ;*
  267. ;*  EFFECTS: Huge shift value is saved in HugeShift
  268. ;*           Screen device driver handle is saved in hScreenDD
  269. ;*
  270. ;*  INTERNAL REFERENCES:
  271. ;*    ROUTINES: NONE
  272. ;*
  273. ;*  EXTERNAL REFERENCES:
  274. ;*    ROUTINES: RegSave, RegRest
  275. ;*
  276. ;****************************************************************************/
  277.  
  278. DEVENABLE PROC  FAR
  279.         public  DEVENABLE
  280.  
  281.         Call    RegSave
  282.  
  283.         mov     ax,-1                   ;Preset PMERR_DEV_FUNC_NOT_INSTALLED
  284.         .if     <<word ptr [bp].stk_function> eq 1> near and
  285.         mov     ax,ERROR_VIO_INTERNAL_RESOURCE
  286.         .if     <[si+4] ae fn_NextAvail> near ;Table large enough for this VDH
  287.  
  288.             push    WDHGSEG
  289.             pop     ds
  290.             .if     <ds:wdh_SISsel eq bx> ;This is 1st call by System ;@T52
  291.  
  292.                 mov     si,offset FnTable ;DS:SI = local table
  293.                 les     di,dword ptr es:[di+4] ;Get Call Table Addr
  294.                 add     di,4*fn_BufferUpdate ;ES:DI = target table
  295.                 mov     cx,fn_NextAvail-fn_BufferUpdate ;# of entries ;D198
  296.                 .repeat             ;D198
  297.                     .if     <<word ptr [si+2]> ne bx> ;Supported ;D198
  298.                         movsd       ;Copy addr to table ;D198           ;@T71
  299.                     .else           ;D198
  300.                         add     si,4 ;D198
  301.                         add     di,4 ;Skip this entry ;D198
  302.                     .endif          ;D198
  303.                 .loop               ;D198
  304.  
  305.                 push    ds
  306.                 push    offset wdh_SISsel  ;GDT selector save area  ;@T52
  307.                 push    ds
  308.                 push    offset wdh_LISsel  ;LDT selector save area  ;@T52
  309.                 Call    DOSGETINFOSEG ;Get selectors of info segments
  310.  
  311.                 mov     es,ds:wdh_SISsel   ;ES = System Info Seg    ;@T52
  312.                 mov     al,es:[bx].SIS_MaxScrnGrp ;get max full-screen SGs
  313.                 cbw
  314.                 dec     al          ;determine the highest full-
  315.                 mov     ds:wdh_LastFS,ax ;@T2                       ;@T52
  316.  
  317.                 push    6           ;Get Prepared CodePages      @C30
  318.                 push    ds          ;@C30
  319.                 push    offset wdh_cpidcurrnt ;@C30                 ;@T52
  320.                 push    ds          ;@C30
  321.                 push    offset wdh_numcpids ;@C30                   ;@T52
  322.                 Call    DOSGETCP    ;@C30
  323.                 shr     ds:wdh_numcpids,1 ;@C30                     ;@T52
  324.             .endif
  325.  
  326.             lgs     si,ds:bvh_instance                              ;@T80
  327.  
  328.             mov     ax,ds:wdh_SISsel                                ;@T52
  329.             mov     gs:[si].cmn_SISsel,ax                           ;@T80
  330.             mov     gs:[si].ppbvs_gdtsel,ax                         ;@T80
  331.  
  332.             mov     ax,ds:wdh_LISsel                                ;@T52
  333.             mov     gs:[si].cmn_LISsel,ax                           ;@T80
  334.             mov     gs:[si].ppbvs_ldtsel,ax ;Setup for AVIO sessions;@T80
  335.  
  336.             mov     es,ax           ;@T2
  337.             mov     ax,es:[bx].LIS_CurScrnGrp ;@T2
  338.             .if     <ax a ds:wdh_LastFS> ;@T2                       ;@T52
  339.                 push    bx          ;@T2
  340.                 call    WININITIALIZE                               ;@T52
  341.                 .if     <zero ax>                                   ;AR07042
  342.                     mov     ax,ERROR_VIO_INTERNAL_RESOURCE          ;AR07042
  343.                 .else                                               ;AR07042
  344.                     sub     ax,ax                                   ;AR07042
  345.                     sub     bx,bx       ;@T2                        ;AR07042
  346.                     call    GREINITIALIZE                           ;@T52
  347.                     .if     <zero ax>                               ;AR07042
  348.                         mov     ax,ERROR_VIO_INTERNAL_RESOURCE      ;AR07042
  349.                     .else                                           ;AR07042
  350.                         sub     ax,ax                               ;AR07042
  351.                     .endif                                          ;AR07042
  352.                 .endif
  353.             .else                   ;@T2
  354.  
  355.                  sub     ax,ax
  356.             .endif                  ;@T2
  357.         .endif                                                      ;AR07042
  358.  
  359.         Call    RegRest
  360.         ret     12
  361. DEVENABLE ENDP
  362.  
  363. ;/****************************************************************************
  364. ;*
  365. ;*  SUBROUTINE NAME: InitEnv
  366. ;*
  367. ;*  DESCRIPTIVE NAME: Initialize environment
  368. ;*
  369. ;*  FUNCTION: InitEnv is called by BVS to initialize the video
  370. ;*            environment during the creation of a new session.  This
  371. ;*            includes initializing the adapter hardware and/or the
  372. ;*            environment buffer.
  373. ;*
  374. ;*  ENTRY POINT: InitEnv
  375. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 257 )
  376. ;*
  377. ;*  INPUT: (Passed on stack)
  378. ;*             FAR *Environment ( Environment buffer for the session )
  379. ;*             FAR *ParmBlock
  380. ;*                     USHORT Length = length of this packet
  381. ;*                     USHORT Flags  = 0 - Environment buffer only
  382. ;*                                     1 - Hardware also
  383. ;*             ULONG Function ( Call vector table entry = 257 )
  384. ;*         (Referenced)
  385. ;*             Modes[] (global data - table of supported video modes )
  386. ;*
  387. ;*  EXIT-NORMAL: AX = 0
  388. ;*               Environment buffer is initialized
  389. ;*
  390. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  391. ;*
  392. ;*  EFFECTS: If requested, display adapter hardware is initialized to
  393. ;*           highest resolution mode supported.
  394. ;*
  395. ;*  INTERNAL REFERENCES:
  396. ;*    ROUTINES: NONE
  397. ;*
  398. ;*  EXTERNAL REFERENCES:
  399. ;*    ROUTINES: NONE
  400. ;*
  401. ;****************************************************************************/
  402.  
  403. InitEnv PROC    FAR
  404.         public  InitEnv
  405.         Call    RegSave
  406.  
  407.         mov     ax,[si].vp_ev_session   ;Session Id for ShellInit       ;@T71
  408.         mov     dx,[si].vp_ev_selector  ;LVB selector
  409.  
  410. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  411.         push    _DATA                                           ;@an07  ;;EPOCH ;; added for J-FUNC
  412.         pop     ds                                              ;@an07  ;;EPOCH ;; added for J-FUNC
  413.                                                                         ;;EPOCH ;; added for J-FUNC
  414.         push    si                                              ;@an07  ;;EPOCH ;; added for J-FUNC
  415.         mov     si,OFFSET BvscbSel                              ;@an07  ;;EPOCH ;; added for J-FUNC
  416.         push    ax                                              ;@an07  ;;EPOCH ;; added for J-FUNC
  417.         xor     ah,ah                                           ;@an07  ;;EPOCH ;; added for J-FUNC
  418.         add     si,ax                                           ;@an07  ;;EPOCH ;; added for J-FUNC
  419.         add     si,ax                                           ;@an07  ;;EPOCH ;; added for J-FUNC
  420.         mov     word ptr ds:[si],0                              ;@an07  ;;EPOCH ;; added for J-FUNC
  421.         pop     ax                                              ;@an07  ;;EPOCH ;; added for J-FUNC
  422.         pop     si                                              ;@an07  ;;EPOCH ;; added for J-FUNC
  423. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  424.         push    WDHGSEG
  425.         pop     ds
  426.         .if     <ah eq PROG_WINDOWABLEVIO> near ;Windowed session?  ;@D549,@T71
  427.  
  428.             cbw                         ;Clear session tyye       ;@D549,@T71
  429.             mov     si,offset ProtoEnv
  430.             sub     di,di
  431.             mov     cx,size wdhenvironment
  432.             push    cx                  ;Save environment size          ;@T71
  433.             shr     cx,2                ;Prepare to move dwords         ;@T71
  434.             rep     movsd               ;Copy prototype enviroment      ;@T71
  435.             pop     cx                  ;Restore environment size       ;@T71
  436.             and     cx,3                ;                               ;@T71
  437.             .if     <nz>                ;Has remainder?                 ;@T71
  438.                 rep     movsb           ;Move them 1 byte at a time     ;@T71
  439.             .endif                      ;                               ;@T71
  440.             mov     si,ax               ;Setup Session # for ShieldInit ;@T71
  441.  
  442. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  443.             mov     es:[bx].env_sessionNum,si                           ;;EPOCH ;; added for J-FUNC
  444. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  445.             mov     es:[bx].viops_Sel_LogicalVideoBuffer,dx
  446.  
  447.             mov     es:[bx].viops_CellByteSize,2
  448.             mov     dword ptr es:[bx].viops_BufferRowCount,0500019h     ;@T71
  449.  
  450.             mov     dword ptr es:[bx].viops_TextCursorStartLine,070006h ;@T71
  451.  
  452. IFDEF D1348 ;get DBCS environment vector.
  453.  
  454.             mov     es:[bx].viops_FormatID,DefaultFormat
  455.             mov     es:[bx].env_attrbytes,DefaultAttrCount
  456.  
  457.             mov     es:[bx].env_funcindx,DefaultFmtIndx
  458.  
  459.             ;/Get dbcs env vectors and set them to environment.
  460.             push    ds                                      ;@A0p
  461.             push    WDHGSEG                                 ;@A0p
  462.             pop     ds                                      ;@A0p
  463.             mov     ax,ds:[wdh_cpid1]                       ;@A0p
  464.             pop     ds                                      ;@A0p
  465.             mov     word ptr es:[bx].env_CtryCode+2,ax      ;@A0p
  466.  
  467.             mov     word ptr es:[bx].env_CtryCode,0
  468.             push    DBCSEvBufSiz
  469.             push    es
  470.             mov     ax,offset env_CtryCode
  471.             push    ax
  472.             push    es
  473.             mov     ax,offset env_DBCSEvBuff
  474.             push    ax
  475.             call    DosGetDBCSEv
  476.                                         ;Ignore the r/c
  477.                                         ;If r/c !=0 ==> env_DBCSEvBuff
  478.                                         ;remains to be zero.
  479.  
  480.                                         ; env_DBCSEvBuff db DBCSEvBufSiz dup (0)
  481.                                         ; env_CtryCode   dw 2 dup (0)
  482.                                         ; env_CodePage   dw ?
  483.             mov     ax,offset env_DBCSEvBuff
  484.             mov     word ptr es:[bx].viops_lpNLSExt,ax  ;make pmavio.dll &
  485.                                                         ;display.dll accesible
  486.                                                         ;to dbcs env.
  487.             mov     ax,es
  488.             mov     word ptr es:[bx].viops_lpNLSExt+2,ax
  489.  
  490.  
  491.             mov     ax,es:[bx].viops_BufferRowCount     ; calc LVB size
  492.             mul     es:[bx].viops_BufferColumnCount
  493.             mul     es:[bx].viops_CellByteSize
  494.             mov     cx,ax                               ; if 64KB, cx = 0000h
  495.             sub     ax,dx                               ; if 64KB, set 0FFFFh
  496.             mov     es:[bx].env_lvbsize,ax
  497.  
  498. ENDIF ;D1348
  499.  
  500. IFDEF DBCSENBL ; prepare the 2nd LVB for DBCS flag                      ;;DBCS  ;; added for J-FUNC
  501.             push    cx                  ; size                          ;;DBCS  ;; added for J-FUNC
  502.             push    es                  ; selector field                ;;DBCS  ;; added for J-FUNC
  503.             push    env_dbcslvbsel                                      ;;DBCS  ;; added for J-FUNC
  504.             push    2                   ; share GetSeg                  ;;DBCS  ;; added for J-FUNC
  505.             call    DOSALLOCSEG         ; allocate                      ;;DBCS  ;; added for J-FUNC
  506.             .if     <zero ax>           ; no error                      ;;DBCS  ;; added for J-FUNC
  507.                 push    es                                              ;;DBCS  ;; added for J-FUNC
  508.                 shr     cx,1            ; clear DBCS flag LVB           ;;DBCS  ;; added for J-FUNC
  509.                 mov     es,es:[bx].env_dbcslvbsel                       ;;DBCS  ;; added for J-FUNC
  510.                 sub     di,di                                           ;;DBCS  ;; added for J-FUNC
  511.                 rep     stosw           ; clear by zero                 ;;DBCS  ;; added for J-FUNC
  512.                 pop     es                                              ;;DBCS  ;; added for J-FUNC
  513.                                                                         ;;DBCS  ;; added for J-FUNC
  514.             .else                                               ;@an01  ;;DBCS  ;; added for J-FUNC
  515.                 mov     ax,ERROR_VIO_INTERNAL_RESOURCE          ;@an01  ;;DBCS  ;; added for J-FUNC
  516.                 jmp     badexit                                 ;@an01  ;;DBCS  ;; added for J-FUNC
  517.             .endif                                                      ;;DBCS  ;; added for J-FUNC
  518. ENDIF ; DBCSENBL                                                        ;;DBCS  ;; added for J-FUNC
  519.  
  520. ;/*
  521. ;** Setup a one word work area and get the mouse event mask for the PSC
  522. ;*/
  523.  
  524.             push    bx                  ;Push work area on stack
  525.             mov     di,sp               ;Get ptr to work area
  526.             sub     eax,eax                                             ;@T71
  527.             push    bx                  ;Reserve a word for Action Taken   @T7
  528.             mov     dx,sp               ;                                  @T7
  529.             push    ds                  ;Pointer to Device Name            @T7
  530.             push    offset Mouse_Name   ;                             @T7;@T52
  531.             push    ss                  ;Pointer to Device Handle returned @T7
  532.             push    di                  ;                                  @T7
  533.             push    ss                  ;Pointer to Action Taken returned  @T7
  534.             push    dx                  ;                                  @T7
  535.             push    eax                 ;                             @T7,@T71
  536.             push    dword ptr 001h      ;Open Flag - fail if not there@T7,@T71
  537.             push    0C2h                ;Open Mode - Private               @T7
  538.             push    eax                 ;                             @T7,@T71
  539.             call    DOSOPEN             ;                                  @T7
  540.  
  541.             .if     <zero ax>
  542.                 mov     dx,ss:[di]
  543.  
  544.                 push    ds
  545.                 push    offset wdh_mouevntmask ;@ of returned event mask;@T52
  546.                 push    dx
  547.                 Call    MOUGETEVENTMASK
  548.  
  549.                 push    dx              ;                                  @T7
  550.                 call    DOSCLOSE        ;                                  @T7
  551.             .endif
  552.             add     sp,4                ;Discard reserved word        @T7,@T71
  553.  
  554. ;/*
  555. ;** Perform shield initialization for this sessi
  556. ;*/
  557.  
  558.             Call    ShieldInit          ;Get console handle
  559.  
  560. ;/*
  561. ;** Perform initialization for AVIO session
  562. ;*/
  563.  
  564.         .else   near                    ;AVIO session
  565.  
  566.             mov     si,offset ProtoEnv+env_conhandle
  567.             mov     di,env_conhandle
  568.             mov     cx,(size wdhenvironment)-env_conhandle
  569.             push    cx                  ;Save original size             ;@T71
  570.             shr     cx,2                ;Prepare to move dwords         ;@T71
  571.             rep     movsd               ;Copy end of prototype env.     ;@T71
  572.             pop     cx                  ;Restore original size          ;@T71
  573.             and     cx,3                ;                               ;@T71
  574.             .if     <nz>                ;Has remainder?                 ;@T71
  575.                 rep     movsb           ;Move them 1 byte at a time     ;@T71
  576.             .endif                      ;                               ;@T71
  577.  
  578.             Call    UpdateMode          ;Update the mode data
  579.  
  580. IFDEF D1348 ;initialize the attr count for AVIO
  581.  
  582.             mov     ax,es:[bx].viops_CellByteSize       ;get cell size
  583.             dec     ax                                  ;conv to attrib count
  584.             mov     es:[bx].env_attrbytes,al            ;save attrib count
  585.  
  586.                                                         ;function index for DBCS
  587.                                                         ;BufferUpdate
  588.             .if     <es:[bx].viops_CellByteSize eq PSCellSize>
  589. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  590.                 mov     ax,es:[bx].viops_FormatID                       ;;EPOCH ;; added for J-FUNC
  591.                 and     al,0fh                                          ;;EPOCH ;; added for J-FUNC
  592.                 .if     <al eq PSFormat>                                ;;EPOCH ;; added for J-FUNC
  593. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  594.                     mov     es:[bx].env_funcindx,PSFmtIndx
  595. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  596.                 .endif                                                  ;;EPOCH ;; added for J-FUNC
  597. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  598.             .elseif <es:[bx].viops_FormatID eq ExtPSFormat>
  599.                 mov     es:[bx].env_funcindx,ExtPSFmtIndx
  600.             .else
  601.                 mov     es:[bx].env_funcindx,WorldFmtIndx
  602.             .endif
  603.  
  604.             mov     ax,es:word ptr [bx].env_fullbufsz
  605.             mov     cx,ax                               ;if 64KB, cx = 0000h
  606.             sub     ax,es:word ptr [bx].env_fullbufsz+2 ;if 64KB, set 0FFFFh
  607.             mov     es:[bx].env_lvbsize,ax
  608.  
  609. IFDEF DBCSENBL ; prepare the 2nd LVB for DBCS flag                      ;;DBCS  ;; added for J-FUNC
  610.             mov     es:[bx].env_dbcslvbsel,0    ; initialize            ;;DBCS  ;; added for J-FUNC
  611.             .if     <es:[bx].viops_CellByteSize eq PSCellSize>          ;;DBCS  ;; added for J-FUNC
  612.                 push    cx                      ; size                  ;;DBCS  ;; added for J-FUNC
  613.                 push    es                      ; selector field        ;;DBCS  ;; added for J-FUNC
  614.                 push    env_dbcslvbsel                                  ;;DBCS  ;; added for J-FUNC
  615.                 push    2                       ; share                 ;;DBCS  ;; added for J-FUNC
  616.                 call    DOSALLOCSEG             ; allocate              ;;DBCS  ;; added for J-FUNC
  617.                 .if     <zero ax>               ; no error              ;;DBCS  ;; added for J-FUNC
  618.                     push    es                                          ;;DBCS  ;; added for J-FUNC
  619.                     shr     cx,1                ; clear DBCS flag LVB   ;;DBCS  ;; added for J-FUNC
  620.                     mov     es,es:[bx].env_dbcslvbsel                   ;;DBCS  ;; added for J-FUNC
  621.                     sub     di,di                                       ;;DBCS  ;; added for J-FUNC
  622.                     rep     stosw               ; clear by zero         ;;DBCS  ;; added for J-FUNC
  623.                     pop     es                                          ;;DBCS  ;; added for J-FUNC
  624.                 .endif                                                  ;;DBCS  ;; added for J-FUNC
  625.             .endif                                                      ;;DBCS  ;; added for J-FUNC
  626. ENDIF ; DBCSENBL                                                        ;;DBCS  ;; added for J-FUNC
  627.             .if     <<dword ptr es:[bx].viops_lpNLSExt> eq 0>   ;@an02
  628.                 ;/Get a default dbcs env vectors and set them to environment.
  629.                 ; These vectors are for lcid = 0(default).
  630.                 push    ds
  631.                 push    WDHGSEG
  632.                 pop     ds
  633.                 mov     ax,ds:[wdh_cpid1]
  634.                 pop     ds
  635.                 mov     word ptr es:[bx].env_CtryCode+2,ax
  636.  
  637.                 mov     word ptr es:[bx].env_CtryCode,0
  638.                 push    DBCSEvBufSiz
  639.                 push    es
  640.                 mov     ax,offset env_CtryCode
  641.                 push    ax
  642.                 push    es
  643.                 mov     ax,offset env_DBCSEvBuff
  644.                 push    ax
  645.                 call    DosGetDBCSEv
  646.                                             ;Ignore the r/c
  647.                                             ;If r/c !=0 ==> env_DBCSEvBuff
  648.                                             ;remains to be zero.
  649.  
  650.                                             ; env_DBCSEvBuff db DBCSEvBufSiz dup (0)
  651.                                             ; env_CtryCode   dw 2 dup (0)
  652.                                             ; env_CodePage   dw ?
  653.                 mov     ax,offset env_DBCSEvBuff
  654.                 mov     word ptr es:[bx].viops_lpNLSExt,ax  ;make pmaviod.ll &
  655.                                                             ;display.dll accesible
  656.                                                             ;to dbcs env.
  657.                 mov     ax,es
  658.                 mov     word ptr es:[bx].viops_lpNLSExt+2,ax
  659.  
  660.             .endif                                              ;@an02
  661. ENDIF ;D1348
  662.  
  663.             sub     ax,ax               ;Force a good return code ;@S18
  664.         .endif
  665.  
  666. IFDEF DBCSENBL                                                          ;;DBCS  ;; added for J-FUNC
  667. badexit:                                                                ;;DBCS  ;; added for J-FUNC
  668. ENDIF ;DBCSENBL                                                         ;;DBCS  ;; added for J-FUNC
  669.         Call    RegRest
  670.         ret     12
  671. InitEnv ENDP
  672.  
  673. ;/****************************************************************************
  674. ;*
  675. ;*  FUNCTION NAME: UpdateMode
  676. ;*
  677. ;*  DESCRIPTION  = Update the mode data from the PSCB
  678. ;*
  679. ;*  INPUT        =
  680. ;*  OUTPUT       =
  681. ;*
  682. ;*  EXIT-NORMAL  =
  683. ;*  EXIT-ERROR   =
  684. ;*
  685. ;****************************************************************************/
  686.  
  687. UpdateMode PROC NEAR
  688.         public  UpdateMode
  689.         push    ax                      ;@T17
  690.         push    ds
  691.  
  692.         push    WDHGSEG                                                 ;@T52
  693.         pop     ds
  694.         lds     bx,ds:bvh_instance                                      ;@T52
  695.         mov     ds,[bx].wdhi_pssel
  696.         sub     bx,bx                                                   ;@T52
  697.         mov     ax,[bx].viops_BufferRowCount ;Get number of rows        ;@@A
  698.         mov     [bx].env_scrlbottom,ax  ;@C22
  699.         dec     [bx].env_scrlbottom     ;@C22
  700.         mov     [bx].env_rows,ax        ;Update mode data               ;@@A
  701.         .if     <ax be 25>              ;@S38;@S38f
  702.             shl     ax,1                ;Simulate 16*TRows=GRows ;@S38
  703.         .endif                          ;@S38
  704.         shl     ax,3                    ;Simulate 8*TRows=GRows ;@S38   ;@@A
  705.         mov     [bx].env_grows,ax       ;Update mode data               ;@@A
  706.         mov     ax,[bx].viops_BufferColumnCount ;Get number of cols
  707.         mov     [bx].env_scrlright,ax   ;@C22
  708.         dec     [bx].env_scrlright      ;@C22
  709.         mov     [bx].env_cols,ax        ;Update mode data
  710.         mul     [bx].env_rows           ;                               ;@@A
  711.         mul     [bx].viops_CellByteSize ;Compute new buffer size
  712.  
  713.         mov     word ptr [bx].env_bufsize,ax
  714.         mov     word ptr [bx].env_bufsize+2,dx
  715.         mov     word ptr [bx].env_fullbufsz,ax
  716.         mov     word ptr [bx].env_fullbufsz+2,dx ;Update mode data
  717.  
  718.         mov     ax,[bx].viops_CellByteSize                              ;AR07027
  719.         dec     al                                                      ;AR07027
  720.         mov     [bx].env_attrbytes,al                                   ;AR07027
  721.  
  722. IFDEF D1348 ;reset formatid.
  723.             ;These two line are applied to the portion other than D2061.
  724.         mov     ax,[bx].viops_FormatID
  725.         mov     byte ptr [bx].env_attrformat,al ;Update mode data
  726. ENDIF ;D1348
  727.  
  728.         pop     ds
  729.         pop     ax                      ;@T17
  730.         ret
  731. UpdateMode ENDP
  732.  
  733. ;/****************************************************************************
  734. ;*
  735. ;*  SUBROUTINE NAME: GetConfig
  736. ;*
  737. ;*  DESCRIPTIVE NAME: Return video adapter configuration information
  738. ;*
  739. ;*  FUNCTION: GetConfig is called by BVS to identify the current
  740. ;*            display adapter.
  741. ;*
  742. ;*  ENTRY POINT: RetConfigInfo
  743. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 260 )
  744. ;*
  745. ;*  INPUT: (Passed on stack)
  746. ;*             FAR *Environment ( Environment buffer for the session )
  747. ;*             FAR *ParmBlock
  748. ;*                     USHORT Length = length of this packet
  749. ;*                     USHORT Flags  = 0 ( reserved )
  750. ;*                     FAR *ConfigData = VioGetConfig structure
  751. ;*             ULONG Function ( Call vector table entry = 260 )
  752. ;*         (Referenced)
  753. ;*             MemorySize (global data - amount of video memory)
  754. ;*
  755. ;*  EXIT-NORMAL: AX = 0
  756. ;*               Configuration data is returned to caller
  757. ;*
  758. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  759. ;*
  760. ;*  EFFECTS: NONE
  761. ;*
  762. ;*  INTERNAL REFERENCES:
  763. ;*    ROUTINES: NONE
  764. ;*
  765. ;*  EXTERNAL REFERENCES:
  766. ;*    ROUTINES: NONE
  767. ;*
  768. ;****************************************************************************/
  769.  
  770. PUBLIC  GETCONFIG   ;06Mar92                                                    ;; added for J-FUNC
  771. GetConfig PROC  FAR
  772.         public  GetConfig
  773.         Call    RegSave
  774.  
  775.         mov     ax,ERROR_VIO_INVALID_LENGTH
  776.         .if     <[si].vp_parmlength eq 8> and
  777.         les     di,dword ptr [si].vp_offset ;Get address of config data
  778.         push    WDHGSEG
  779.         pop     ds
  780.         mov     si,offset Config        ;Get offset of config data
  781.         mov     cx,es:[di].cf_length    ;Get length of config data
  782.         .if     <cx a 1>
  783.  
  784.             mov     ax,cx
  785.             .if     <al a <size configdata>> ;@S25
  786.                 mov     al,cf_confignum ;@S25
  787.             .endif                      ;@S25
  788.  
  789.             push    di
  790.             sub     al,size cf_length
  791.             .if     <ns>
  792.                 movsw
  793.             .endif
  794.  
  795.             sub     al,size cf_adapter
  796.             .if     <ns>
  797.                 movsw
  798.             .endif
  799.  
  800.             sub     al,size cf_display
  801.             .if     <ns>
  802.                 movsw
  803.             .endif
  804.  
  805.             sub     al,size cf_memory
  806.             .if     <ns>
  807.                 movsd                                                   ;@T71
  808.             .endif
  809.  
  810.             sub     al,size cf_confignum
  811.             .if     <ns>
  812.                 movsw
  813.             .endif
  814.  
  815.             sub     al,size cf_version
  816.             .if     <ns>
  817.                 movsw
  818.             .endif
  819.  
  820.             sub     al,size cf_flags
  821.             .if     <ns>
  822.                 movsw
  823.             .endif
  824.  
  825.             sub     al,size cf_envsize
  826.             .if     <ns>
  827.                 movsd                                                   ;@T71
  828.             .endif
  829.  
  830.             sub     al,size cf_fullsize
  831.             .if     <ns>
  832.                 movsd                                                   ;@T71
  833.             .endif
  834.  
  835.             sub     al,size cf_partsize
  836.             .if     <ns>
  837.                 movsd                                                   ;@T71
  838.             .endif
  839.  
  840.             sub     al,size cf_adapteroff
  841.             .if     <ns>
  842.                 movsw
  843.             .endif
  844.  
  845.             sub     al,size cf_displayoff
  846.             .if     <ns>
  847.                 movsw
  848.             .endif
  849.  
  850.             sub     al,size cf_emadapters
  851.             .if     <ns>
  852.                 movsw
  853.             .endif
  854.  
  855.             sub     al,size cf_emdisplays
  856.             .if     <ns>
  857.                 movsw
  858.             .endif
  859.  
  860.             mov     ax,di
  861.             pop     di
  862.             sub     ax,di
  863.             .if     <al a 2>            ;More than just a length request
  864.                 stosw                   ;Update length in Mode data
  865.             .endif
  866.  
  867.             sub     ax,ax               ;Set good return code
  868.         .endif
  869.  
  870.         Call    RegRest
  871.         ret     12
  872. GetConfig ENDP
  873.  
  874. ;/****************************************************************************
  875. ;*
  876. ;*  SUBROUTINE NAME: ExtVIO
  877. ;*
  878. ;*  DESCRIPTIVE NAME: Extended VIO subroutines
  879. ;*
  880. ;*  FUNCTION:  This routine processes the following Extended VIO
  881. ;*             functions:
  882. ;*
  883. ;*             43h     (067)   VioFree
  884. ;*             50h     (080)   VioAssociate
  885. ;*             51h     (081)   VioCreatePS
  886. ;*             52h     (082)   VioDeleteSetId
  887. ;*             53h     (083)   VioDestroyPS
  888. ;*             54h     (084)   VioGetDeviceCellSize
  889. ;*             55h     (085)   VioGetOrg
  890. ;*             56h     (086)   VioCreateLogFont
  891. ;*             57h     (087)   VioQuerySetIds
  892. ;*             58h     (088)   VioQueryFonts
  893. ;*             59h     (089)   VioSetDeviceCellSize
  894. ;*             5Ah     (090)   VioSetOrg
  895. ;*             5Bh     (091)   VioShowPS
  896. ;*             5Ch     (092)   VioGetPSAddress
  897. ;*             61h     (097)   Shield Termination
  898. ;*             62h     (098)   Query Console
  899. ;*
  900. ;*  ENTRY POINT: ExtVIO
  901. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entries )
  902. ;*
  903. ;*  INPUT: (Passed on stack)
  904. ;*             FAR *Environment ( Environment buffer for the session )
  905. ;*             FAR *ParmBlock
  906. ;*             ULONG Function ( Call vector table entry )
  907. ;*
  908. ;*  EXIT-NORMAL: AX = return code from Extended VIO function
  909. ;*
  910. ;*  EXIT-ERROR: None
  911. ;*
  912. ;*  EFFECTS: Reports that function is not valid for extended sessions.
  913. ;*
  914. ;*  INTERNAL REFERENCES:
  915. ;*    ROUTINES: NONE
  916. ;*
  917. ;*  EXTERNAL REFERENCES:
  918. ;*    ROUTINES: NONE
  919. ;*
  920. ;****************************************************************************/
  921.  
  922. ExtVIO  PROC    FAR
  923.         public  ExtVIO
  924.         Call    RegSave
  925.  
  926.         mov     dx,[si].p_viofunc
  927.         .if     <dl eq -1>              ;Validate AVIO handle
  928.             mov     ax,ERROR_VIO_INVALID_HANDLE ;Preset error
  929.  
  930.             push    WDHGSEG                                             ;@T52
  931.             pop     gs                                                  ;@T80
  932.             les     bx,gs:bvh_instance                                  ;@T80
  933.  
  934.             mov     di,[si].p_viohandle ;Get the handle number
  935.             add     di,di
  936.             mov     cx,es:[bx][di].addr_list ;Locate the PS selector    ;@T52
  937.             .if     <ncxz>              ;PS selector in instance data
  938.                 mov     si,[si].vp_ev_session                      ;@T52,@T71
  939.                 mov     ds,cx                                           ;@T52
  940.                 mov     ax,ds:[viops_Sel_BVSControlBlock]               ;@T52
  941.                 mov     dx,ds:[viops_Sel_LogicalVideoBuffer]            ;@T52
  942.  
  943.                 mov     es:[bx].ppbvs_bvssel,ax
  944.                 mov     es:[bx].ppbvs_pssel,cx
  945.                 mov     es:[bx].ppbvs_lvbsel,dx ;Local selectors for AVIO
  946.  
  947.                 shl     si,2            ;adjust for dword offset  ;@D549,@T71
  948.                 lds     di,gs:bvs_global                          ;@D549;@T80
  949.                 add     di,si                                      ;@T52,@T71
  950.                 lds     di,ds:[di].bvsgSelTable                         ;@T52
  951.  
  952.                 mov     ds:[di].selt_bvscb,ax                      ;@S10,@D549
  953.                 mov     ds:[di].selt_envb,cx                       ;@S10,@D549
  954.                 mov     ds:[di].selt_lvb,dx ;Update the BVS SelSeg ;@S10,@D549
  955.  
  956.                 mov     es:[bx].bvsi_bvs,ax                             ;@T52
  957.                 mov     es:[bx].bvsi_env,cx                             ;@T52
  958.                 mov     es:[bx].bvsi_lvb,dx ;Update BVS Instance data   ;@T52
  959.  
  960.                 sub     ax,ax
  961.             .endif
  962.  
  963.         .else   near
  964.  
  965. IFDEF DBCSENBL  ; prepare the 2nd LVB for DBCS flag                     ;;DBCS  ;; added for J-FUNC
  966.             .if     <dl eq vf_DestroyPS> and                            ;;DBCS  ;; added for J-FUNC
  967.             .if     <es:[bx].env_dbcslvbsel ne 0>                       ;;DBCS  ;; added for J-FUNC
  968.                 push    es:[bx].env_dbcslvbsel  ; DBCS flag LVB sel     ;;DBCS  ;; added for J-FUNC
  969.                 call    DOSFREESEG              ; free selector         ;;DBCS  ;; added for J-FUNC
  970.                 mov     es:[bx].env_dbcslvbsel,0                        ;;DBCS  ;; added for J-FUNC
  971.             .endif                                                      ;;DBCS  ;; added for J-FUNC
  972. ENDIF ; DBCSENBL                                                        ;;DBCS  ;; added for J-FUNC
  973.             .if     <dl eq vf_QueryConsole>
  974.                 Call    QueryConsole
  975.             .else   near
  976.                 .if     <dl eq vf_Free> or
  977.                 .if     <dl eq vf_ShieldTerm>
  978. IFDEF DBCSENBL                                                          ;;DBCS  ;; added for J-FUNC
  979.                     .if     <es:[bx].env_dbcslvbsel ne 0>       ;@B01   ;;DBCS  ;; added for J-FUNC
  980.                             .if     <<es:[bx+2].viops_lpNLSExt> ne 0> and       ;; added for J-FUNC
  981.                                 mov     ax,es                           ;;DBCS  ;; added for J-FUNC
  982.                             .if     <<word ptr es:[bx+2].viops_lpNLSExt> ne ax> ;; added for J-FUNC
  983.                                                                         ;;DBCS  ;; added for J-FUNC
  984.                                 push    word ptr es:[bx+2].viops_lpNLSExt       ;; added for J-FUNC
  985.                                 Call    DOSFREESEG  ;Relinquish use of work buffer      ;;   J-FUNC
  986.                             .endif                                      ;;DBCS  ;; added for J-FUNC
  987.                             mov     word ptr es:[bx].viops_lpNLSExt,0    ;zap offset    ;;   J-FUNC
  988.                             mov     word ptr es:[bx+2].viops_lpNLSExt,0  ;zap selector  ;;   J-FUNC
  989.                             push    es:[bx].env_dbcslvbsel      ;@B01   ;;DBCS  ;; added for J-FUNC
  990.                             Call    DOSFREESEG  ;Relinquish use of work buffer ;@B01    ;;   J-FUNC
  991.                             mov     es:[bx].env_dbcslvbsel,0    ;@B01   ;;DBCS  ;; added for J-FUNC
  992.                     .endif                                      ;@B01   ;;DBCS  ;; added for J-FUNC
  993. ENDIF ; DBCSENBL                                                        ;;DBCS  ;; added for J-FUNC
  994.                     Call    ShieldTerm
  995.                 .else   near            ;AVIO calls
  996.                     push    bp
  997.                     .if     <dl e vf_DestroyPS> ;@B25
  998.                         push    ds              ;@B25
  999.                         push    si              ;@B25
  1000.                     .endif                      ;@B25
  1001.  
  1002.  
  1003.                     ;/*
  1004.                     ;****** AVIO depends on BP setup with the first    *****
  1005.                     ;****** struc member of oldstackframe in BVSCB.INC *****
  1006.                     ;*/
  1007.  
  1008.                     lea     bp,[si].p_regfs     ;@c16;@D549 needs to change from
  1009.                     mov     di,[si].vp_ev_selector
  1010.                     mov     si,dx       ;AVIO expects SI = function number
  1011.  
  1012.                     push    WDHGSEG
  1013.                     pop     ds
  1014.                     lds     bx,ds:bvh_instance                          ;@T52
  1015.  
  1016.                     mov     ax,ERROR_VIO_EXTENDED_SG
  1017.                     .if     <dl eq vf_CreatePS>
  1018.  
  1019.                         Call    AVIOSUBS                                ;@T52
  1020.                     .else               ;All other AVIO calls need CX = INSTSEG
  1021.  
  1022.                         .if     <dl ae vf_AssociateDC> and
  1023.                         .if     <dl be vf_GetPSAddress>
  1024.  
  1025.                             Call    SecureSema4
  1026.                             push    dx
  1027.                             Call    AVIOSUBS                            ;@T52
  1028.                             pop     dx
  1029.                             .if     <dl ne vf_DestroyPS>
  1030.                                 .if     <dl eq vf_SetDevCellSz>
  1031.                                     Call    UpdateMode
  1032.                                 .endif
  1033.                                 Call    ReleaseSema4
  1034.                             .else               ;@B25
  1035.                                 pop     si      ;@B25 recover ds,si if DestroyPS
  1036.                                 pop     ds      ;@B25
  1037.                                 mov     ax,[si].vp_ev_session ;Get SG # ;@B25;@T52
  1038.                                 push    WDHGSEG                         ;@T52
  1039.                                 pop     ds                              ;@T52
  1040.                                 shl     ax,2    ;align dword offset ;@D549;@T52
  1041.                                 lds     di,ds:bvs_global          ;@D549;@T52
  1042.                                 add     di,ax                           ;@T52
  1043.                                 lds     di,ds:[di].bvsgSelTable         ;@T52
  1044.                                 sub     bx,bx                           ;@T52
  1045.                                 mov     ds:[di].selt_bvscb,bx;@B25,@D549,@T71
  1046.                                 mov     ds:[di].selt_envb,bx ;@B25,@D549,@T71
  1047.                                 mov     ds:[di].selt_lvb,bx  ;@B25,@D549,@T71
  1048.  
  1049.                                 sub     ax,ax                           ;@B48
  1050.  
  1051.                             .endif
  1052.                         .endif
  1053.                     .endif
  1054.                     pop     bp
  1055.                 .endif
  1056.             .endif
  1057.         .endif
  1058.  
  1059.         Call    RegRest
  1060.         ret     12
  1061. ExtVIO  ENDP
  1062.  
  1063. ;/****************************************************************************
  1064. ;*
  1065. ;*  SUBROUTINE NAME: WDHError
  1066. ;*
  1067. ;*  DESCRIPTIVE NAME: WDH Error Stub for unsupported functions
  1068. ;*
  1069. ;*  FUNCTION: This routine returns ERROR_VIO_EXTENDED_SG in response
  1070. ;*            to all of the following functions:
  1071. ;*
  1072. ;*             106h   (262)   Get Color Lookup Table
  1073. ;*             107h   (263)   Set Color Lookup Table
  1074. ;*             10Ah   (266)   Get Font
  1075. ;*             10Bh   (267)   Set Font
  1076. ;*             10Eh   (270)   Get Palette Registers
  1077. ;*             10Fh   (271)   Set Palette Registers
  1078. ;*             110h   (272)   Get Phys Buf
  1079. ;*             111h   (273)   Free Phys Buf
  1080. ;*
  1081. ;*  ENTRY POINT: WDHError
  1082. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entries )
  1083. ;*
  1084. ;*  INPUT: (Passed on stack)
  1085. ;*             FAR *Environment ( Environment buffer for the session )
  1086. ;*             FAR *ParmBlock
  1087. ;*             ULONG Function ( Call vector table entry )
  1088. ;*
  1089. ;*  EXIT-NORMAL: AX = ERROR_VIO_EXTENDED_SG
  1090. ;*
  1091. ;*  EXIT-ERROR: None
  1092. ;*
  1093. ;*  EFFECTS: Reports that function is not valid for extended sessions.
  1094. ;*
  1095. ;*  INTERNAL REFERENCES:
  1096. ;*    ROUTINES: NONE
  1097. ;*
  1098. ;*  EXTERNAL REFERENCES:
  1099. ;*    ROUTINES: NONE
  1100. ;*
  1101. ;****************************************************************************/
  1102.  
  1103. WDHError PROC   FAR
  1104.         public  WDHError
  1105.  
  1106.         mov     ax,ERROR_VIO_EXTENDED_SG
  1107.         ret     12
  1108. WDHError ENDP
  1109.  
  1110. ;/****************************************************************************
  1111. ;*
  1112. ;*  SUBROUTINE NAME: WDHDummy
  1113. ;*
  1114. ;*  DESCRIPTIVE NAME: WDH Dummy Stub for unsupported functions
  1115. ;*
  1116. ;*  FUNCTION: This routine returns AX = 0 in response to all of the
  1117. ;*            following functions, while actually doing nothing:
  1118. ;*
  1119. ;*             102h   (258)   Save Environment
  1120. ;*             103h   (259)   Restore Environment
  1121. ;*
  1122. ;*  ENTRY POINT: WDHDummy
  1123. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entries )
  1124. ;*
  1125. ;*  INPUT: (Passed on stack)
  1126. ;*             FAR *Environment ( Environment buffer for the session )
  1127. ;*             FAR *ParmBlock
  1128. ;*             ULONG Function ( Call vector table entry )
  1129. ;*
  1130. ;*  EXIT-NORMAL: AX = 0
  1131. ;*
  1132. ;*  EXIT-ERROR: None
  1133. ;*
  1134. ;*  EFFECTS: Reports that function is was successful, but does nothing.
  1135. ;*
  1136. ;*  INTERNAL REFERENCES:
  1137. ;*    ROUTINES: NONE
  1138. ;*
  1139. ;*  EXTERNAL REFERENCES:
  1140. ;*    ROUTINES: NONE
  1141. ;*
  1142. ;****************************************************************************/
  1143.  
  1144. WDHDummy PROC   FAR
  1145.         public  WDHDummy
  1146.  
  1147.         sub     ax,ax
  1148.         ret     12
  1149. WDHDummy ENDP
  1150.  
  1151. ;/****************************************************************************
  1152. ;*
  1153. ;* FUNCTION NAME = RegSave/RegRest
  1154. ;*
  1155. ;* DESCRIPTION   = Save and Restore all registers and flags for VDH routines.
  1156. ;*                 RegSave also sets BX=0, DS:SI=ParmBlock, and ES:DI=EnvBlock
  1157. ;*
  1158. ;* INPUT         = NONE
  1159. ;* OUTPUT        = NONE
  1160. ;*
  1161. ;* RETURN-NORMAL = NONE
  1162. ;* RETURN-ERROR  = NONE
  1163. ;*
  1164. ;****************************************************************************/
  1165.  
  1166. RegSave PROC    NEAR                    ;Routine to save regs
  1167.         public  RegSave
  1168.  
  1169.         pop     ax                      ;Get return address
  1170.         pushf
  1171.         pushad                          ;changed from pusha, because if
  1172.                                         ;we call PM, high 16-bits can be trashed
  1173.         push    ds
  1174.         push    es                      ;Save all registers and flags
  1175.         push    gs                                                       ;@T80
  1176.         cld
  1177.         mov     bp,sp
  1178.         push    ax                      ;Restore return address
  1179.  
  1180.         les     di,dword ptr [bp].stk_envblock ;ES:DI = Environment Block
  1181.  
  1182.         push    WDHGSEG                                                 ;@T52
  1183.         pop     ds
  1184.         lds     bx,ds:bvh_instance                                      ;@T52
  1185.         mov     [bx].wdhi_pssel,es      ;Save PS selector in instance data
  1186.  
  1187.         lds     si,dword ptr [bp].stk_parmblock ;DS:SI = Parameter Block
  1188.         sub     bx,bx                   ;Get zero reg for code optimization
  1189.  
  1190.         ret
  1191. RegSave ENDP
  1192.  
  1193. RegSav2 PROC    NEAR                    ;Routine to save regs
  1194.         public  RegSav2
  1195.  
  1196.         pop     ax                      ;Get return address
  1197.         pushf
  1198.         pushad                          ;changed from pusha, because if
  1199.                                         ;we call PM, high 16-bits can be trashed
  1200.         push    ds
  1201.         push    es                      ;Save all registers and flags
  1202.         push    gs                                                      ;@T80
  1203.         cld
  1204.         mov     bp,sp
  1205.         push    ax                      ;Restore return address
  1206.  
  1207.         ret
  1208. RegSav2 ENDP
  1209.  
  1210. RegRest PROC    NEAR                    ;Routine to restore regs
  1211.         public  RegRest
  1212.  
  1213.         mov     [bp].stk_regax,ax       ;Save return code
  1214.         pop     ax
  1215.         xchg    [bp].stk_flags,ax       ;Swap return address w/flags
  1216.         push    ax
  1217.  
  1218.         popf
  1219.         pop     gs                                                      ;@T80
  1220.         pop     es
  1221.         pop     ds
  1222.         popad                           ;Restore all registers and flags
  1223.  
  1224.         ret
  1225. RegRest ENDP
  1226.  
  1227. R2CSEG  ENDS
  1228.         END
  1229.  
  1230.