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