home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / AVIO.ASM next >
Assembly Source File  |  1995-04-14  |  64KB  |  1,500 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    ,132
  13.  
  14. ;/****************************************************************************
  15. ;*
  16. ;* SOURCE FILE NAME = AVIO.ASM
  17. ;*
  18. ;* DESCRIPTIVE NAME = Avio specific routines
  19. ;*
  20. ;*
  21. ;* VERSION      V2.0
  22. ;*
  23. ;* DATE
  24. ;*
  25. ;* DESCRIPTION  This module contains routines that run at ring 2:
  26. ;*              Avio specific routines
  27. ;*
  28. ;* FUNCTIONS    AVIOSUBS
  29. ;*              VioAssociate
  30. ;*              VioCreatePS
  31. ;*              CreateAvio
  32. ;*              VioDestroyPS
  33. ;*              VioGetDeviceCellSize
  34. ;*              VioGetOrg
  35. ;*              VioQuerySetIds
  36. ;*              VioSetDeviceCellSize
  37. ;*              VioSetOrg
  38. ;*              VioShowPS
  39. ;*              VioGetPSAddress
  40. ;*              VioCreateLogFont
  41. ;*              VioDeleteSetId
  42. ;*              VioQueryFonts
  43. ;*              _NULLCHARRECT
  44. ;*              SetNLSbits
  45. ;*              HeadBounds
  46. ;*              PutDBCSs
  47. ;*              TailBounds
  48. ;*              PutDBCSinEnds
  49. ;*              Writes
  50. ;*              CheckDBCS
  51. ;*
  52. ;* NOTES        NONE
  53. ;*
  54. ;* STRUCTURES   NONE
  55. ;*
  56. ;* EXTERNAL REFERENCES   GREENTRY4:FAR
  57. ;*                       GREENTRY5:FAR
  58. ;*                       GREENTRY6:FAR
  59. ;*                       GREENTRY8:FAR
  60. ;*                       DOSALLOCSEG:FAR
  61. ;*                       DOSFREESEG:FAR
  62. ;*                       DOSGETCP:FAR
  63. ;*                       DOSGETCTRYINFO:FAR
  64. ;*
  65. ;* EXTERNAL FUNCTIONS
  66. ;*
  67. ;*              NONE
  68. ;*
  69. ;* CHANGE ACTIVIY =
  70. ;*   FLAG        APAR    CHANGE DESCRIPTION
  71. ;*   ----------  -----   --------------------------------------
  72. ;*   @Vr.mpppxx  xxxxx   xxxxxxx
  73. ;*   @P1         PTR6415 0300 890126 HDHVG all data to instance NSEG
  74. ;*   @P2         PTR6583 0300 890126 HDHVG alter initialisation of BVSCB for VDH
  75. ;*   @P3         PTR6584 0300 890126 HDHVG remove save of ds around DosFreeSeg
  76. ;*   @P4         PTR7442 0300 890918 HDRL  save FormatID/Reserved for IBMJapan
  77. ;*   @P5         AR06846 1.3  900921 TPL   do not return internal resource error
  78. ;*   @P6         MSD2061 1.3  910215 AN    set dbcs bits for common lvb format
  79. ;*               D1348   1348  2.0  910411 NAKADA    Enable DBCS in Window,
  80. ;*   @T83        AR12264 2.0  920221 TPL       Alloc the entire env buffer here
  81. ;*   @@SW        62978   2.1  930303 TPL   Increase # of PS from 32 to 128
  82. ;*
  83. ;******************************************************************************/
  84.  
  85.  
  86. EXTRN   GREENTRY4:FAR
  87. EXTRN   GREENTRY5:FAR
  88. EXTRN   GREENTRY6:FAR
  89. EXTRN   GREENTRY8:FAR
  90. EXTRN   DOSALLOCSEG:FAR
  91. EXTRN   DOSFREESEG:FAR
  92. EXTRN   DOSGETCP:FAR
  93. EXTRN   DOSGETCTRYINFO:FAR
  94. IFDEF DBCSENBL                  ;@B02                                   ;;DBCS  ;; added for J-FUNC
  95. EXTRN   DOSGETDBCSEV:FAR        ;@B02                                   ;;DBCS  ;; added for J-FUNC
  96. ENDIF ;DBCSENBL                 ;@B02                                   ;;DBCS  ;; added for J-FUNC
  97. EXTRN   AVIOCREATEPS:NEAR
  98. EXTRN   AVIOASSOCIATE:NEAR
  99. EXTRN   AVIODESTROYPS:NEAR
  100. EXTRN   AVIOSETDEVICECELLSIZE:NEAR
  101. EXTRN   AVIOSETORG:NEAR
  102. EXTRN   AVIODELETESETID:NEAR
  103. EXTRN   AVIOQUERYSETIDS:NEAR
  104. EXTRN   AVIOQUERYFONTS:NEAR
  105. EXTRN   ClearGreDat:NEAR                                                ;@T52
  106. EXTRN   EngineCharRect:NEAR                                             ;@T52
  107.  
  108. EXTRN   bvh_instance:DWORD      ; BVH per process data                  ;@T52
  109.  
  110. Public  AVIOSUBS
  111. Public  _NULLCHARRECT                                                   ;@T52
  112. Public  VioAssociate
  113. Public  VioCreatePS
  114. Public  CreateAvio
  115. Public  VioDeleteSetId
  116. Public  VioDestroyPS
  117. Public  VioGetDeviceCellSize
  118. Public  VioGetOrg
  119. Public  VioCreateLogFont
  120. Public  VioQuerySetIds
  121. Public  VioQueryFonts
  122. Public  VioSetDeviceCellSize
  123. Public  VioSetOrg
  124. Public  VioShowPS
  125. Public  VioGetPSAddress
  126. .xlist
  127. INCLUDE cmacros.inc
  128.  
  129. ;/*
  130. ;** OS2 includes
  131. ;*/
  132.  
  133. INCL_NOCOMMOM equ 1
  134. INCLUDE os2def.inc
  135.  
  136. INCL_ERRORS equ 1
  137. INCLUDE BSEERR.INC
  138.  
  139. ;/*
  140. ;** OS2P includes
  141. ;*/
  142.  
  143. INCLUDE pmwinx.inc
  144. ;INCL_WINP equ 1
  145. INCL_AVIOP equ 1
  146. ;INCLUDE os2p.inc
  147. INCLUDE pmaviop.inc
  148.  
  149. ;/*
  150. ;** PMDDI includes
  151. ;*/
  152.  
  153. INCL_GRE_STRINGS equ 1
  154. INCL_GRE_FONTS equ 1
  155. INCL_GRE_SETID equ 1
  156. INCLUDE pmddi.inc
  157.  
  158. INCLUDE bvscb.inc
  159. INCL_ERRORS equ 1
  160. INCLUDE struc.inc
  161. INCLUDE BvsEQU.inc
  162. INCLUDE wdhequ.inc                                                      ;@T83
  163. .list
  164.  
  165.         public  __acrtused              ;Do not use C runtime           ;@T52
  166. __acrtused = 1                          ;  initialization code          ;@T52
  167.  
  168. avio3seg        equ     <R2CSEG>                                        ;@T52
  169.  
  170. cp_cpid EQU     parmn                   ;new code page id ;@@1;@@3
  171. cp_parmoff EQU  parmn                   ;offset to the return data area ;@@1
  172. cp_parmsel EQU  parmnm1                 ;selector to the return data area ;@@1
  173.  
  174. IFDEF D1348
  175. WorldFormat     equ     70h             ; world format ID(common lvb format id)
  176. DBCSFlag        equ     01h             ; dbcs bit
  177. TrailByteFlag   equ     80h             ; dbcs trailing bit
  178.                                         ; dbcs leading byte  : 01h in attr #3
  179.                                         ; dbcs trailing byte : 81h in attr #3
  180. lcid_mask       equ     00000011B
  181. ENDIF ;D1348
  182.  
  183. avio3seg segment word Public 'code'                                     ;@T52
  184.         Assume  cs:avio3seg,DS:NOTHING,ES:NOTHING
  185.  
  186. ;/***************************************************************************
  187. ;*
  188. ;* FUNCTION NAME = AVIOSUBS
  189. ;*
  190. ;* DESCRIPTION   =
  191. ;*
  192. ;* INPUT         = DS:BX -> BVHINSTANCE data
  193. ;*                 SI    -  AVIO function code
  194. ;*
  195. ;* OUTPUT        = DS:BX -> BVHINSTANCE data
  196. ;*                 AX    -  Appropriate error code
  197. ;*                 All others are destroyed
  198. ;*
  199. ;* RETURN-NORMAL = NONE
  200. ;* RETURN-ERROR  = NONE
  201. ;*
  202. ;**************************************************************************/
  203.  
  204. AVIOSUBS Proc   FAR
  205.  
  206.  
  207.         .if     <si ae 50h> and         ;range check function code
  208.         .if     <si be 5Ch>
  209.             sub     si,50h              ;normalise SI
  210.             add     si,si               ;make SI an index to jump table
  211.             push    ds                                                  ;@T52
  212.             push    bx                                                  ;@T52
  213.             call    cs:AvioTbl[si]
  214.             pop     bx                                                  ;@T52
  215.             pop     ds                                                  ;@T52
  216.         .else
  217.             mov     ax,error_vio_mode   ;SI function code out of range
  218.         .endif
  219.         ret
  220.  
  221. AVIOSUBS endp
  222.  
  223. ;/*
  224. ;** AVIO function jump table :
  225. ;*/
  226.  
  227. AvioTbl dw      VioAssociate            ; 50h
  228.         dw      VioCreatePS             ; 51h
  229.         dw      VioDeleteSetId          ; 52h  Delete Logical Font
  230.         dw      VioDestroyPS            ; 53h
  231.         dw      VioGetDeviceCellSize    ; 54h
  232.         dw      VioGetOrg               ; 55h
  233.         dw      VioCreateLogFont        ; 56h
  234.         dw      VioQuerySetIds          ; 57h
  235.         dw      VioQueryFonts           ; 58h
  236.         dw      VioSetDeviceCellSize    ; 59h
  237.         dw      VioSetOrg               ; 5Ah
  238.         dw      VioShowPS               ; 5Bh
  239.         dw      VioGetPSAddress         ; 5Ch
  240.  
  241. ;/*
  242. ;** Start of AVIO functions :
  243. ;*/
  244.  
  245. ;/***************************************************************************
  246. ;*
  247. ;* FUNCTION NAME = VioAssociate
  248. ;*
  249. ;* DESCRIPTION   =
  250. ;*
  251. ;* INPUT         = NONE
  252. ;* OUTPUT        = NONE
  253. ;*
  254. ;* RETURN-NORMAL = NONE
  255. ;* RETURN-ERROR  = NONE
  256. ;*
  257. ;**************************************************************************/
  258.  
  259. VioAssociate Proc NEAR
  260.         push    ds:[bx].ppbvs_pssel ;PresSpace Sel                      ;@T52
  261.         push    0                ;Pres Space offset
  262.         push    [bp].viohandle   ;AVio handle
  263.         push    [bp].parmnm1     ;DC handle pt 1
  264.         push    [bp].parmn       ;DC handle pt 2
  265.         call    AVIOASSOCIATE
  266.         ret
  267. VioAssociate endp
  268.  
  269. ;/***************************************************************************
  270. ;*
  271. ;* FUNCTION NAME = VioCreatePS
  272. ;*
  273. ;* DESCRIPTION   =
  274. ;*
  275. ;* INPUT         = DS:BX -> BVHINSTANCE data
  276. ;* OUTPUT        = NONE
  277. ;*
  278. ;* RETURN-NORMAL = NONE
  279. ;* RETURN-ERROR  = NONE
  280. ;*
  281. ;**************************************************************************/
  282.  
  283. VioCreatePS Proc NEAR
  284.         mov     si,2                             ;get...
  285.         mov     cx,0                             ;...
  286.         mov     ax,1                             ;...next...
  287.         .while  <cx b 128> and                   ;...                   ;@@SW
  288.         .while  <nonzero ax>                     ;...free...            ;@T52
  289.             mov     ax,[bx].addr_list[si]        ;...
  290.             inc     cx                           ;...Avio...
  291.             inc     si                           ;...
  292.             inc     si                           ;...handle
  293.         .endwhile
  294.         .if     <zero ax>                        ;cx = handle           ;@T52
  295.             mov     ax,error_vio_invalid_parms   ;preset error condition
  296.             .if     <[bp].parmn eq 1> or
  297.             .if     <[bp].parmn eq 3>            ;num attr ok
  298.                 .if     <[bp].parmnm2 be 255> and
  299.                 .if     <[bp].parmnm3 be 255>    ;width/depth ok
  300.                     .if     <[bp].viohandle eq 0>;reserved ok
  301.                         mov     ax,[bp].parmnm2  ;width
  302.                         mul     [bp].parmnm3     ;depth
  303.                         .if     <zero dx> and                           ;@T52
  304.                         .if     <nonzero ax>     ;width * depth         ;@T52
  305.                             .if     <ax be 4000h> and
  306.                             .if     <[bp].parmn eq 3>
  307.                                 call    CreateAvio ;width*depth*numattr ok
  308.                             .else
  309.                                 .if     <ax be 8000h> and
  310.                                 .if     <[bp].parmn eq 1>
  311.                                     call    CreateAvio
  312.                                 .else
  313.                                     mov     ax,error_vio_invalid_parms
  314.                                 .endif
  315.                             .endif
  316.                         .else
  317.                             mov     ax,error_vio_invalid_parms
  318.                         .endif
  319.                     .endif
  320.                 .endif
  321.             .endif
  322.         .else
  323.             mov     ax,error_vio_no_more_handles
  324.         .endif
  325.         ret
  326.  
  327. VioCreatePS endp
  328.  
  329. ;/***************************************************************************
  330. ;*
  331. ;* FUNCTION NAME = CreateAvio
  332. ;*
  333. ;* DESCRIPTION   =
  334. ;*
  335. ;* INPUT         = DS:BX -> BVHINSTANCE data
  336. ;*                 CX    -  AVIO handle (index)
  337. ;* OUTPUT        = NONE
  338. ;*
  339. ;* RETURN-NORMAL = NONE
  340. ;* RETURN-ERROR  = NONE
  341. ;*
  342. ;**************************************************************************/
  343.  
  344. CreateAvio Proc NEAR
  345.  
  346.  
  347.         .if     <[bx].ppbvs_gdtsel eq 0>  ;not yet initiallised         ;@T52
  348.             mov     ax,ds:[bx].cmn_SISsel ;                             ;@T52
  349.             mov     [bx].ppbvs_gdtsel,ax  ;System Info Seg GDT
  350.             mov     ax,ds:[bx].cmn_LISsel ;                             ;@T52
  351.             mov     [bx].ppbvs_ldtsel,ax  ;System Info Seg LDT
  352.         .endif
  353.         mov     di,ds                            ;save BVSNSEG
  354.         lds     si,dword ptr [bp].parmnm4        ;get recipient for handle ...
  355.         mov     ds:[si],cx                       ;...and put it in
  356.         mov     si,cx                            ;get vio handle...
  357.         add     si,si                            ;...adjust to make index...
  358.         push    si                               ;...and save it
  359.                                                  ; 
  360.                                                  ;allocate PS seg
  361.                                                  ; 
  362.         mov     cx,size wdhenvironment                                  ;@T83
  363.         push    cx                               ;length of PS + Shield/Gre Data
  364.         mov     ds,di                            ;reset BVSNSEG
  365.         push    ds                               ;recipient seg
  366.         lea     ax,ds:[bx].ppbvs_pssel           ;recipient offset      ;@T52
  367.         push    ax                                                      ;@T52
  368.         push    2
  369.         call    DosAllocSeg
  370.         .if     <nonzero ax>                                            ;@T52
  371.             mov    ds:[bx].ppbvs_pssel,0         ;alloc failed
  372.         .else  near
  373.             mov     ax,ds:[bx].ppbvs_pssel       ;alloc ok
  374.             mov     ds:[bx].addr_list[si],ax     ; 
  375.             mov     es,ax                        ;PS alloc ok , now init PS
  376.             mov     al,0                         ; 
  377.             sub     di,di
  378.             rep     stosb
  379.             mov     ax,[bp].parmnm3
  380.             mov     es:[viops_BufferRowCount],ax                        ;@T52
  381.             mov     ax,[bp].parmnm2
  382.             mov     es:[viops_BufferColumnCount],ax                     ;@T52
  383.             mov     ax,[bp].parmnm1              ;                       @P4A
  384. IFDEF EPOCH ;02Oct91 +                                                  ;;EPOCH ;; added for J-FUNC
  385.             ;AVio does not support any epoch format. So just in case,   ;;EPOCH ;; added for J-FUNC
  386.             ;set internal epoch color format.                           ;;EPOCH ;; added for J-FUNC
  387.             .if     <ax eq 1>                                           ;;EPOCH ;; added for J-FUNC
  388.                 mov     al,41h                   ;Set epoch color       ;;EPOCH ;; added for J-FUNC
  389.                                                  ;internal format       ;;EPOCH ;; added for J-FUNC
  390.             .endif                                                      ;;EPOCH ;; added for J-FUNC
  391. ENDIF       ;02Oct91 -                                                  ;;EPOCH ;; added for J-FUNC
  392.             mov     es:[viops_FormatID],ax       ;                  @P4A;@T52
  393.             mov     ax,[bp].viohandle            ;                       @P4A
  394.             mov     es:[viops_Reserved],ax       ;                  @P4A;@T52
  395.             mov     ax,[bp].parmn
  396.             inc     ax
  397.             mov     es:[viops_CellByteSize],ax                          ;@T52
  398.             push    2
  399.             push    es
  400.             push    viops_CodepageID                                    ;@T52
  401.             push    ds
  402.             lea     ax,ds:[bx].Scratch_Area1                            ;@T52
  403.             push    ax                                                  ;@T52
  404.             call    DosGetCP
  405.             .if     <es:[viops_CodepageID] eq 0>                        ;@T52
  406.  
  407.                 mov     ds:[bx].wdhi_start_row,0                        ;@T52
  408.                 mov     word ptr ds:[bx].wdhi_start_row+2,0             ;@T52
  409.                 push    4                                               ;@T52
  410.                 push    ds                                              ;@T52
  411.                 lea     ax,ds:[bx].wdhi_start_row                       ;@T52
  412.                 push    ax                                              ;@T52
  413.                 push    ds                                              ;@T52
  414.                 lea     ax,ds:[bx].wdhi_start_col                       ;@T52
  415.                 push    ax                                              ;@T52
  416.                 push    ds                                              ;@T52
  417.                 lea     ax,ds:[bx].wdhi_length_width                    ;@T52
  418.                 push    ax                                              ;@T52
  419.                 call    DosGetCtryInfo
  420.                 mov     ax,ds:[bx].wdhi_start_col+2                     ;@T52
  421.                 .if     <zero ax>                                       ;@T52
  422.                     mov     ax,850
  423.                 .endif
  424.                 mov     es:[viops_CodepageID],ax                        ;@T52
  425.             .endif
  426.                                                  ; 
  427.                                                  ;Allocate LVB seg
  428.                                                  ; 
  429.             mov     ax,[bp].parmnm2              ;width
  430.             mul     [bp].parmnm3                 ;depth
  431.             mov     cx,[bp].parmn                ;num attr
  432.             inc     cx
  433.             mul     cx
  434.             mov     ds:[bx].Scratch_Area2,ax
  435.             push    ax                           ;length of LVB
  436.             mov     si,ax                        ;save length for later
  437.             push    es                           ;selector for LVB seg recipient
  438.             push    viops_Sel_LogicalVideoBuffer ;offset to receive LVB seg
  439.             push    2
  440.             call    DosAllocSeg
  441.             .if     <nonzero ax>                                        ;@T52
  442.                 mov    es:[viops_Sel_LogicalVideoBuffer],0 ;alloc failed;@T52
  443.             .else  near
  444.                 sub     di,di                    ;LVB alloc ok , now init LVB
  445.                 mov     cx,si                    ; 
  446.                 mov     es,es:[viops_Sel_LogicalVideoBuffer]            ;@T52
  447.                 shr     cx,1
  448.                 .if     <[bp].parmn eq 1>        ;1 attr byte
  449.                     mov     ax,0720h
  450.                     rep     stosw
  451.                 .else                            ;3 attr bytes
  452.                     shr     cx,1
  453.                     .repeat
  454.                         mov     ax,0720h
  455.                         stosw
  456.                         sub     ax,ax                                   ;@T52
  457.                         stosw
  458.                     .loop
  459.                 .endif
  460.                 mov     es,ds:[bx].ppbvs_pssel   ;                      ;@T52
  461.                                                  ;Alloc BVSCB seg
  462.                                                  ; 
  463.                 mov     cx,ds:[bx].cmn_bvscbsize ; computed length
  464.                 push    cx                       ; of BVSCB
  465.                 push    es
  466.                 push    viops_Sel_BVSControlBlock ;recipient address
  467.                 push    2
  468.                 call    DosAllocSeg
  469.                 .if     <nonzero ax>                                    ;@T52
  470.                     mov    es:[viops_Sel_BVSControlBlock],0 ;alloc failed;@T52
  471.                 .else  near
  472.                     sub     di,di                ; 
  473.                     mov     cx,ds:[bx].cmn_bvscbsize ; BVSCB alloc ok,  ;@T52
  474.                     mov     dx,cx                ; save bvscb size       @P2A
  475.                     shr     cx,1                 ; now init it
  476.                     mov     es,es:[viops_Sel_BVSControlBlock]           ;@T52
  477.                                                  ;ds=PSCD,es=BVSCB       @P2A
  478.                     sub     ax,ax
  479.                     rep     stosw
  480.                     mov     es:[bvs_bvssize],dx  ; size of bvscb    @P2A;@T52
  481.                                                                         ;6@P2D
  482.                     mov     es,ds:[bx].ppbvs_pssel                      ;@T52
  483.                     mov     es:[viops_TextCursorVisible],1              ;@T52
  484.                                                                         ;5@P2D
  485.                     mov     es:[viops_rgfShieldStates],fHasTheFocus+fCursorIsOn ;@T52
  486.                                                                         ;3@P2D
  487.                     mov     ax,es:[viops_Sel_BVSControlBlock]      ;@P2M;@T52
  488.                     mov     ds:[bx].ppbvs_bvssel,ax                ;@P2C;@T52
  489.                     mov     ax,es:[viops_CellByteSize]        ;@P2M @P2C;@T52
  490.                     mov     ds:[bx].cell_size,ax                        ;@P2C
  491. IFDEF DBCSENBL  ;16mar92    ;jc20 js03087                               ;;DBCS  ;; added for J-FUNC
  492. .386p                                                                   ;;DBCS  ;; added for J-FUNC
  493.                     .if     <<dword ptr es:[viops_lpNLSExt]> eq 0>      ;;DBCS  ;; added for J-FUNC
  494.                         push    size VIOPSNLSEXT                        ;;DBCS  ;; added for J-FUNC
  495.                         push    es                                      ;;DBCS  ;; added for J-FUNC
  496.                         push    viops_lpNLSExt+2 ;recipient address     ;;DBCS  ;; added for J-FUNC
  497.                         push    2                                       ;;DBCS  ;; added for J-FUNC
  498.                         call    DosAllocSeg                             ;;DBCS  ;; added for J-FUNC
  499.                         .if     <nonzero ax>                            ;;DBCS  ;; added for J-FUNC
  500.                             mov     dword ptr es:[viops_lpNLSExt],0 ;alloc failed       ;;   J-FUNC
  501.                         .else                                           ;;DBCS  ;; added for J-FUNC
  502.                             mov     ax,word ptr es:[viops_lpNLSExt+2]   ;;DBCS  ;; added for J-FUNC
  503.                             call    ClearSel                            ;;DBCS  ;; added for J-FUNC
  504.                             Local_ctrycode  equ     4                   ;;DBCS  ;; added for J-FUNC
  505.                             wCodepage       equ     ss:[bp][-2]         ;;DBCS  ;; added for J-FUNC
  506.                             wCountryCode    equ     ss:[bp][-4]         ;;DBCS  ;; added for J-FUNC
  507.                                                                         ;;DBCS  ;; added for J-FUNC
  508.                             enter   Local_ctrycode,0    ;get temporary storage  ;; added for J-FUNC
  509.                                                         ;for local variables    ;; added for J-FUNC
  510.                                                                         ;;DBCS  ;; added for J-FUNC
  511.                             push    es                                  ;;DBCS  ;; added for J-FUNC
  512.                             push    di                                  ;;DBCS  ;; added for J-FUNC
  513.                                                                         ;;DBCS  ;; added for J-FUNC
  514.                             mov     word ptr wCountryCode,0             ;;DBCS  ;; added for J-FUNC
  515.                             mov     ax,es:[viops_CodepageID]            ;;DBCS  ;; added for J-FUNC
  516.                             mov     word ptr wCodepage,ax               ;;DBCS  ;; added for J-FUNC
  517.                                                                         ;;DBCS  ;; added for J-FUNC
  518.                             push    DBCSEvBufSiz                        ;;DBCS  ;; added for J-FUNC
  519.                             push    ss                                  ;;DBCS  ;; added for J-FUNC
  520.                             mov     ax,bp               ;get wCountryCode       ;; added for J-FUNC
  521.                             sub     ax,4                                ;;DBCS  ;; added for J-FUNC
  522.                             push    ax                                  ;;DBCS  ;; added for J-FUNC
  523.                             les     di,dword ptr es:[viops_lpNLSExt]    ;;DBCS  ;; added for J-FUNC
  524.                             add     di,offset viopsnlsext_DBCSEvInfo    ;;DBCS  ;; added for J-FUNC
  525.                             add     di,offset dbcsenvinfo_DBCSVector    ;;DBCS  ;; added for J-FUNC
  526.                             push    es                                  ;;DBCS  ;; added for J-FUNC
  527.                             push    di                                  ;;DBCS  ;; added for J-FUNC
  528.                             call    DosGetDBCSEv                        ;;DBCS  ;; added for J-FUNC
  529.                                                         ;Ignore the r/c ;;DBCS  ;; added for J-FUNC
  530.                                                         ;If r/c !=0 ==> env_DBCSEvBuff  ;;   J-FUNC
  531.                                                         ;remains to be zero.    ;; added for J-FUNC
  532.                                                                         ;;DBCS  ;; added for J-FUNC
  533.                                 ; env_DBCSEvBuff db DBCSEvBufSiz dup (0);;DBCS  ;; added for J-FUNC
  534.                                 ; env_CtryCode   dw 2 dup (0)           ;;DBCS  ;; added for J-FUNC
  535.                                 ; env_CodePage   dw ?                   ;;DBCS  ;; added for J-FUNC
  536.                                                                         ;;DBCS  ;; added for J-FUNC
  537.                             mov     dword ptr es:[di].viopsnlsext_grid_color,0fcfcfch   ;;   J-FUNC
  538.                             mov     dword ptr es:[di].viopsnlsext_scrnattrflag,0        ;;   J-FUNC
  539.                             pop     di                                  ;;DBCS  ;; added for J-FUNC
  540.                             pop     es                                  ;;DBCS  ;; added for J-FUNC
  541.                                                                         ;;DBCS  ;; added for J-FUNC
  542.                             leave                                       ;;DBCS  ;; added for J-FUNC
  543.                         .endif                                          ;;DBCS  ;; added for J-FUNC
  544.                     .endif                                              ;;DBCS  ;; added for J-FUNC
  545. .286p                                                                   ;;DBCS  ;; added for J-FUNC
  546. ENDIF           ;16mar92                                                ;;DBCS  ;; added for J-FUNC
  547.  
  548. ;/*
  549. ;** go get an IC for the new PS
  550. ;*/
  551.  
  552.                     push    bx                                          ;@T52
  553.                     push    es               ;PresSpace Sel
  554.                     push    0                ;Pres Space offset
  555.                     les     di,dword ptr [bp].parmnm4
  556.                     push    es:[di]          ;AVio handle
  557.                     call    AVIOCREATEPS
  558.                     pop     bx                                          ;@T52
  559.                     .if     <zero ax>                                   ;@T52
  560.                         call    _NULLCHARRECT                           ;@T52
  561.                         push    ds                                      ;@T52
  562.                         mov     ds,[bx].ppbvs_pssel ;ds=PSCB
  563.                         mov     ax,ds:[viops_CellImageHeight]           ;@T52
  564.                         dec     ax
  565.                         mov     ds:[viops_TextCursorStartLine],ax       ;@T52
  566.                         mov     ds:[viops_TextCursorEndLine],ax         ;@T52
  567.                         mov     ax,ds:[viops_CellImageWidth]            ;@T52
  568.                         mov     ds:[viops_TextCursorWidth],ax           ;@T52
  569.                         mov     ax,ds:[viops_BufferRowCount]            ;@T52
  570.                         dec     ax
  571.                         mov     ds:[viops_TextCursorRow],ax             ;@T52
  572.                         sub     ax,ax
  573.                         pop     ds                                      ;@T52
  574.                     .endif
  575.                 .endif
  576.             .endif
  577.         .endif
  578.         pop     si
  579.         .if     <nonzero ax>                                            ;@T52
  580.             .if     <ds:[bx].ppbvs_pssel ne 0>
  581.                     mov     es,ds:[bx].ppbvs_pssel                      ;@T52
  582.                     .if     <es:[viops_Sel_LogicalVideoBuffer] ne 0>    ;@T52
  583.                             push    es:[viops_Sel_LogicalVideoBuffer]   ;@T52
  584.                             call    DosFreeSeg          ;release LVB
  585.                             .if     <es:[viops_Sel_BVSControlBlock] ne 0> ;@T52
  586.                                     push    es:[viops_Sel_BVSControlBlock] ;@T52
  587.                                     call    DosFreeSeg  ;release BVSCB
  588.                             .endif
  589.                     .endif
  590.                     push    ds:[bx].ppbvs_pssel                         ;@T52
  591.                     call    DosFreeSeg                  ;release PS
  592.             .endif
  593.             mov     ds:[bx].addr_list[si],0
  594.         .endif
  595.         ret
  596. CreateAvio endp
  597.  
  598. ;/***************************************************************************
  599. ;*
  600. ;* FUNCTION NAME = VioDestroyPS
  601. ;*
  602. ;* DESCRIPTION   =
  603. ;*
  604. ;* INPUT         = DS:BX -> BVHINSTANCE data
  605. ;* OUTPUT        = NONE
  606. ;*
  607. ;* RETURN-NORMAL = NONE
  608. ;* RETURN-ERROR  = NONE
  609. ;*
  610. ;**************************************************************************/
  611.  
  612. VioDestroyPS Proc NEAR
  613.         mov     es,ds:[bx].ppbvs_pssel                                  ;@T52
  614.         push    bx                                                      ;@T52
  615.         push    es               ;PresSpace Sel                         ;@T52
  616.         push    0                ;Pres Space offset
  617.         call    AVIODESTROYPS
  618.         pop     bx                                                      ;@T52
  619.         .if     <zero ax>                                               ;@T52
  620.             mov     es,ds:[bx].ppbvs_pssel                              ;@T52
  621.             push    es:[viops_Sel_LogicalVideoBuffer] ;release          ;@T52
  622.             call    DosFreeSeg                   ;...LVB...
  623.             .if     <zero ax>                    ;...and...             ;@T52
  624.                 mov     ax,es:[viops_Sel_BVSControlBlock] ;...          ;@T52
  625.                 push    ax                       ;...
  626.                 call    DosFreeSeg               ;...BVSCB...
  627.                 .if     <zero ax>                ;...and...             ;@T52
  628.                     push    es                   ;...                   ;@T52
  629.                     call    DosFreeSeg           ;...PS
  630.                     .if     <zero ax>            ; if ok then copy
  631.                         mov     si,[bp].viohandle;get VIO handle
  632.                         add     si,si            ;make into index
  633.                         mov     ds:[bx].addr_list[si],0;clear slot in BVSNSEG
  634.                     .endif
  635.                 .endif
  636.             .endif
  637.         .endif
  638.         ret
  639. VioDestroyPS endp
  640.  
  641. ;/***************************************************************************
  642. ;*
  643. ;* FUNCTION NAME = VioGetDeviceCellSize
  644. ;*
  645. ;* DESCRIPTION   =
  646. ;*
  647. ;* INPUT         = DS:BX -> BVHINSTANCE data
  648. ;* OUTPUT        = NONE
  649. ;*
  650. ;* RETURN-NORMAL = NONE
  651. ;* RETURN-ERROR  = NONE
  652. ;*
  653. ;**************************************************************************/
  654.  
  655. VioGetDeviceCellSize Proc NEAR
  656.         mov     ds,ds:[bx].ppbvs_pssel                                  ;@T52
  657.         les     di,dword ptr [bp].parmn
  658.         mov     ax,ds:[viops_CellImageWidth]                            ;@T52
  659.         stosw
  660.         les     di,dword ptr [bp].parmnm2
  661.         mov     ax,ds:[viops_CellImageHeight]                           ;@T52
  662.         stosw
  663.         sub     ax,ax
  664.         ret
  665. VioGetDeviceCellSize endp
  666.  
  667. ;/***************************************************************************
  668. ;*
  669. ;* FUNCTION NAME = VioGetOrg
  670. ;*
  671. ;* DESCRIPTION   =
  672. ;*
  673. ;* INPUT         = DS:BX -> BVHINSTANCE data
  674. ;* OUTPUT        = NONE
  675. ;*
  676. ;* RETURN-NORMAL = NONE
  677. ;* RETURN-ERROR  = NONE
  678. ;*
  679. ;**************************************************************************/
  680.  
  681. VioGetOrg Proc  Near
  682.         mov     ds,ds:[bx].ppbvs_pssel                                  ;@T52
  683.         les     di,dword ptr [bp].parmn          ;col
  684.         mov     ax,ds:[viops_WindowOriginColumn]                        ;@T52
  685.         stosw
  686.         les     di,dword ptr [bp].parmnm2        ;row
  687.         .if     <ds:[viops_WindowHeight] eq 0> and ;never associated    ;@T52
  688.         .if     <ds:[viops_WindowOriginRow] eq 0>  ;.. or had a SetOrg. ;@T52
  689.             sub     ax,ax
  690.         .else
  691.             mov     ax,ds:[viops_BufferRowCount]  ;adjust bottom left.. ;@T52
  692.             sub     ax,ds:[viops_WindowHeight]    ;...relationship to.. ;@T52
  693.             sub     ax,ds:[viops_WindowOriginRow] ;...be top left of LVB;@T52
  694.         .endif
  695.         stosw
  696.         sub     ax,ax
  697.         ret
  698. VioGetOrg endp
  699.  
  700. ;/***************************************************************************
  701. ;*
  702. ;* FUNCTION NAME = VioQuerySetIds
  703. ;*
  704. ;* DESCRIPTION   =
  705. ;*
  706. ;* INPUT         = DS:BX -> BVHINSTANCE data
  707. ;* OUTPUT        = NONE
  708. ;*
  709. ;* RETURN-NORMAL = NONE
  710. ;* RETURN-ERROR  = NONE
  711. ;*
  712. ;**************************************************************************/
  713.  
  714. VioQuerySetIds Proc NEAR
  715.         push    ds:[bx].ppbvs_pssel ;PresSpace Sel
  716.         push    0                ;Pres Space offset
  717.         push    [bp].parmnm1                 ;number pt 1
  718.         push    [bp].parmn                   ;number pt 2
  719.         push    [bp].parmnm3                 ;types pt 1
  720.         push    [bp].parmnm2                 ;types pt 2
  721.         push    [bp].parmnm5                 ;names pt 1
  722.         push    [bp].parmnm4                 ;names pt 2
  723.         push    [bp].parmnm7                 ;LCIDS pt 1 (recipient addr)
  724.         push    [bp].parmnm6                 ;LCIDS pt 2 (recipient addr)
  725.         call    AVIOQUERYSETIDS
  726.         ret
  727. VioQuerySetIds endp
  728.  
  729. ;/***************************************************************************
  730. ;*
  731. ;* FUNCTION NAME = VioSetDeviceCellSize
  732. ;*
  733. ;* DESCRIPTION   =
  734. ;*
  735. ;* INPUT         = DS:BX -> BVHINSTANCE data
  736. ;* OUTPUT        = NONE
  737. ;*
  738. ;* RETURN-NORMAL = NONE
  739. ;* RETURN-ERROR  = NONE
  740. ;*
  741. ;**************************************************************************/
  742.  
  743. VioSetDeviceCellSize Proc NEAR
  744.         push    ds:[bx].ppbvs_pssel                                     ;@T52
  745.         push    0                ;Pres Space offset
  746.         push    [bp].parmn       ;requested cell image width
  747.         push    [bp].parmnm1     ;requested cell image height
  748.         call    AVIOSETDEVICECELLSIZE
  749.         ret
  750. VioSetDeviceCellSize endp
  751.  
  752. ;/***************************************************************************
  753. ;*
  754. ;* FUNCTION NAME = VioSetOrg
  755. ;*
  756. ;* DESCRIPTION   =
  757. ;*
  758. ;* INPUT         = DS:BX -> BVHINSTANCE data
  759. ;* OUTPUT        = NONE
  760. ;*
  761. ;* RETURN-NORMAL = NONE
  762. ;* RETURN-ERROR  = NONE
  763. ;*
  764. ;**************************************************************************/
  765.  
  766. VioSetOrg Proc  NEAR
  767.         mov     ds,ds:[bx].ppbvs_pssel                                  ;@T52
  768.         mov     cx,[bp].parmn                    ;col
  769.         sub     ax,ax
  770.         .if     <cx b 0> or
  771.         .if     <cx ae ds:[viops_BufferColumnCount]>                    ;@T52
  772.             mov     ax,error_vio_col
  773.         .endif
  774.         .if     <zero ax>                                               ;@T52
  775.             mov     dx,[bp].parmnm1              ;row
  776.             .if     <dx ae 0> and
  777.             .if     <dx b ds:[viops_BufferRowCount]>                    ;@T52
  778.                 push    ds               ;PresSpace Sel
  779.                 push    0                ;Pres Space offset
  780.                 push    dx               ;new org row
  781.                 push    cx               ;new org col
  782.                 call    AVIOSETORG
  783.             .else
  784.                 mov     ax,error_vio_row
  785.             .endif
  786.         .endif
  787.         ret
  788. VioSetOrg endp
  789.  
  790. ;/***************************************************************************
  791. ;*
  792. ;* FUNCTION NAME = VioShowPS
  793. ;*
  794. ;* DESCRIPTION   =
  795. ;*
  796. ;* INPUT         = DS:BX -> BVHINSTANCE data
  797. ;* OUTPUT        = NONE
  798. ;*
  799. ;* RETURN-NORMAL = NONE
  800. ;* RETURN-ERROR  = NONE
  801. ;*
  802. ;**************************************************************************/
  803.  
  804. VioShowPS Proc  NEAR
  805.         call    ClearGreDat
  806.         mov     es,ds:[bx].ppbvs_pssel                                  ;@T52
  807.         mov     ax,[bp].parmn                     ;offset in LVB
  808.         .if     <ax l 0>
  809.             mov     ax,error_vio_invalid_parms
  810.         .else   near
  811.             cwd
  812.             div     es:[viops_BufferColumnCount] ;ax=start row, dx=start col ;@T52
  813.             mov     cx,ax
  814.             .if     <ax a es:[viops_BufferRowCount]>                    ;@T52
  815.                 mov     ax,error_vio_invalid_parms
  816.             .else   near
  817.                 mov     ax,es:[viops_BufferRowCount] ;adjust for bottom..;@T52
  818.                 sub     ax,cx                     ;...left LVB origin
  819.                 mov     ds:[bx].wdhi_start_row,ax ;start row            ;@T52
  820.                 mov     ds:[bx].wdhi_start_col,dx ;start col            ;@T52
  821.                 mov     ax,[bp].parmnm1           ;width
  822.                 .if     <ax a es:[viops_BufferColumnCount]> or          ;@T52
  823.                 .if     <ax b 0>
  824.                     mov     ax,error_vio_invalid_parms
  825.                 .else   near
  826.                     mov     ds:[bx].wdhi_length_width,ax                ;@T52
  827.                     mov     ax,[bp].parmnm2       ;depth
  828.                     .if     <ax a ds:[bx].wdhi_start_row> or            ;@T52
  829.                     .if     <ax b 0>
  830.                         mov     ax,error_vio_invalid_parms
  831.                     .else   near    ;@A2
  832.                         sub     ds:[bx].wdhi_start_row,ax;normalise     ;@T52
  833.                         mov     ds:[bx].wdhi_rect_height,ax             ;@T52
  834.  
  835. IFDEF D1348 ;BufferUpdate with dbcs bits handling
  836.                         .if     <<byte ptr es:[viops_FormatID]> eq WorldFormat> near
  837.                             push    ax
  838.                             push    bx
  839.                             push    cx
  840.                             push    dx
  841.                             push    es
  842.                             push    di
  843.                             push    si
  844. ;@A1 +
  845.                             mov     cx,dx               ;save "start col"       ;; added for J-FUNC
  846.                             add     dx,[bp].parmnm1     ;start col + width      ;; added for J-FUNC
  847.                             .if     <dx a <es:[viops_BufferColumnCount]>>       ;; added for J-FUNC
  848.                                 mov     dx,es:[viops_BufferColumnCount]         ;; added for J-FUNC
  849.                                 sub     dx,cx                                   ;; added for J-FUNC
  850.                                 mov     [bp].parmnm1,dx ;adjust the specified width     ;;   J-FUNC
  851.                             .endif                                              ;; added for J-FUNC
  852. ;@A1 -
  853.                             push    es
  854.                             pop     ds
  855.                             mov     cx,es:[viops_Sel_LogicalVideoBuffer]
  856.                             mov     es,cx
  857.                                                         ;(Depth-1)*ColCount+Width
  858.                                                         ;= whole length
  859.                             dec     ax                  ;dec Depth
  860.                             mul     ds:[viops_BufferColumnCount]
  861.                             add     ax,[bp].parmnm1     ;width
  862.                             mov     cx,ax               ;set liner length
  863.  
  864.                             mov     ax,[bp].parmn       ;cell-offset in LVB
  865.                             mul     ds:[viops_CellByteSize]
  866.                             mov     di,ax               ;di=offset in byte
  867.  
  868.                             xor     ax,ax
  869.                             push    cx
  870.                             push    bx          ;@A4                            ;; added for J-FUNC
  871.                             mov     cx,[bp].parmn       ;cell-offset in LVB
  872.  
  873.                             mov     si,bx               ;save               ;@A3
  874.  
  875.                             mov     bx,ds:[viops_CellByteSize]
  876.                             .if     <cx a 0>
  877.  
  878.                                 ; To improve the performance of showing the ps  ;@A3 +
  879.                                 ;  many SBCS characters.
  880.                                 ; Assumption:
  881.                                 ;       There is no orphan DBCS-trailing-byte
  882.                                 ;       created by overwriting.
  883.                                 ;       We can assume this, because each writing
  884.                                 ;       routine smashed bisected DBCS trailing
  885.                                 ;       bytes to be SBCSs.
  886.                                 ; Method:
  887.                                 ; 
  888.                                 ;       +--rectangle to be shown---+
  889.                                 ;     XY|Z                         |
  890.                                 ;       .                          |
  891.                                 ;       .                          |
  892.                                 ; 
  893.                                 ;    where,
  894.                                 ;    X,Y,Z : a cell
  895.                                 ; 
  896.                                 ;    When the attribute bytes of Y and Z don't
  897.                                 ;    have dbcs bit(s) on and the code points of
  898.                                 ;    Y and Z are of SBCS,
  899.                                 ;    if the attr of X has no dbcs bit on and
  900.                                 ;    the code point is of SBCS, we can think X is
  901.                                 ;    a SBCS or a DBCS trailing byte.
  902.                                 ;    In this case we can believe Y is a real SBCS
  903.                                 ;    (not a trailing byte), so we can start DBCS bits
  904.                                 ;    maintenance from Z.
  905.  
  906.                                 ; ds : viops_*
  907.                                 push    bx
  908.                                 mov     bx,si
  909.                                 mov     al,byte ptr es:[di]
  910.                                 mov     ah,byte ptr es:[di+2]
  911.                                 call    CheckDBCS
  912.                                 pop     bx
  913.                                 .if     <nc>
  914.                                     test    byte ptr es:[di+3], DBCSFlag+TrailByteFlag ;check myself
  915.                                     .if     <z>
  916.                                         sub     di,bx
  917.                                         .if     <ns> and
  918.                                         .if     <nc>
  919.                                             push    bx
  920.                                             mov     bx,si
  921.                                             mov     al,byte ptr es:[di]
  922.                                             mov     ah,byte ptr es:[di+2]
  923.                                             call    CheckDBCS
  924.                                             pop     bx
  925.                                             .if     <nc>
  926.                                                 test    byte ptr es:[di+3], DBCSFlag+TrailByteFlag ;check the previous one
  927.                                                 .if     <z>
  928.                                                     sub     di,bx
  929.                                                     .if     <ns> and
  930.                                                     .if     <ns>
  931.                                                         push    bx
  932.                                                         mov     bx,si
  933.                                                         mov     al,byte ptr es:[di]
  934.                                                         mov     ah,byte ptr es:[di+2]
  935.                                                         call    CheckDBCS
  936.                                                         pop     bx
  937.                                                         .if     <nc>
  938.                                                             ;check the previous one of the previous
  939.                                                             test    byte ptr es:[di+3], DBCSFlag+TrailByteFlag
  940.                                                             .if     <z>
  941.                                                                 ;let's start checking dbcs bits from here.
  942.                                                                 add     di,bx   ;undo
  943.                                                                 add     di,bx   ;undo
  944.                                                                 pop     bx
  945.                                                                 pop     cx
  946.                                                                 jmp     Do_shortcut
  947.                                                             .endif
  948.                                                         .endif
  949.                                                     .endif
  950.                                                     add     di,bx   ;undo
  951.                                                 .endif
  952.                                             .endif
  953.                                         .endif
  954.                                         add     di,bx   ;undo
  955.                                     .endif                                        ;@A3 -
  956.                                 .endif                                        ;@A3 -
  957.  
  958.                                 mov     ax,cx           ;save
  959.                                 .repeat                 ;keep the upper compatible
  960.                                                         ;for dbcs applications.
  961.                                                         ;Avio must ensure all
  962.                                                         ;of dbcs bits are valid.
  963.                                     test    byte ptr es:[di+3], DBCSFlag+TrailByteFlag
  964.                                     jnz     @F
  965.                                     sub     di,bx
  966.                                 .loop
  967.                             @@:
  968.                                 mov     dl, byte ptr es:[di+3]              ;@A2
  969.                                 and     dl, DBCSFlag+TrailByteFlag          ;@A2
  970.                                 .if     <bit dl and TrailByteFlag> and      ;@A2
  971.                                 .if     <nonzero cx>
  972.                                     sub     di,bx       ;Look at the dbcs leading byte ;@A2
  973.                                     dec     cx
  974.                                 .endif
  975.                                 sub     ax,cx
  976.                             .endif
  977.                             pop     bx      ;@A4
  978.                             pop     cx
  979.                             add     cx,ax
  980.                     Do_shortcut:    ;@A4
  981.                             mov     ax,di               ;di=offset in byte
  982.                             mov     si,ax
  983.  
  984.                             call    setNLSbits
  985.                             pop     si
  986.                             pop     di
  987.                             pop     es
  988.                             pop     dx
  989.                             pop     cx
  990.                             pop     bx
  991.                             pop     ax
  992.                         .endif
  993. ENDIF ;D1348
  994.  
  995.                         call    EngineCharRect
  996.                     .endif
  997.                 .endif
  998.             .endif
  999.         .endif
  1000.         ret
  1001. VioShowPS endp
  1002.  
  1003. ;/***************************************************************************
  1004. ;*
  1005. ;* FUNCTION NAME = VioGetPSAddress
  1006. ;*
  1007. ;* DESCRIPTION   =
  1008. ;*
  1009. ;* INPUT         = DS:BX -> BVHINSTANCE data
  1010. ;* OUTPUT        = NONE
  1011. ;*
  1012. ;* RETURN-NORMAL = NONE
  1013. ;* RETURN-ERROR  = NONE
  1014. ;*
  1015. ;**************************************************************************/
  1016.  
  1017. VioGetPSAddress Proc NEAR
  1018.         mov     si,[bp].viohandle               ;get handle for PS
  1019.         add     si,si                           ;make it an index
  1020.         sub     ax,ax                           ;ps addr offset
  1021.         mov     dx,ds:[bx].addr_list[si]        ;get the PS seg for handle
  1022.         les     di, dword ptr [bp].parmn        ;get recipient address
  1023.         stosw                                   ;return offset to recipient
  1024.         mov     ax,dx
  1025.         stosw                                   ;return sel to recipient
  1026.         sub     ax,ax                           ;set good return code
  1027.         ret
  1028. VioGetPSAddress endp
  1029.  
  1030. ;/***************************************************************************
  1031. ;*
  1032. ;* FUNCTION NAME = VioCreateLogFont
  1033. ;*
  1034. ;* DESCRIPTION   =
  1035. ;*
  1036. ;* INPUT         = DS:BX -> BVHINSTANCE data
  1037. ;* OUTPUT        = NONE
  1038. ;*
  1039. ;* RETURN-NORMAL = NONE
  1040. ;* RETURN-ERROR  = NONE
  1041. ;*
  1042. ;**************************************************************************/
  1043.  
  1044. VioCreateLogFont Proc NEAR
  1045.         mov     ds,ds:[bx].ppbvs_pssel                                  ;@T52
  1046.         mov     ax,[bp].parmnm2                  ;LCID value
  1047.         .if     <[bp].parmnm3 e 0> and
  1048.         .if     <ax ae 1> and
  1049.         .if     <ax be 3>
  1050.             push    word ptr ds:[viops_hConsoleDisplayContext+2] ;DCh pt 1 ;@T52
  1051.             push    word ptr ds:[viops_hConsoleDisplayContext] ;DCh pt 2   ;@T52
  1052.             inc     ax
  1053.             neg     ax                           ;put LCID 1..3 in range -2..-4
  1054.             push    -1                           ;hi part of LCID word
  1055.             push    ax                           ;lo part of LCID word
  1056.             push    [bp].parmnm1                 ;NAME selector
  1057.             push    [bp].parmn                   ;NAME offset
  1058.             push    [bp].parmnm5                 ;FONTMETRICS selector
  1059.             push    [bp].parmnm4                 ;FONTMETRICS offset
  1060.             push    0                            ;"cookie" parm pt 1
  1061.             push    0                            ;              pt 2
  1062.             push    seg_CreateLogicalFont        ;Engine function pt. 1
  1063.             push    off_CreateLogicalFont        ;Engine function pt. 2
  1064.             call    GREENTRY6
  1065.             .if     <zero ax>                                           ;@T52
  1066.                 mov     ax,error_vio_see_error_log
  1067.             .else
  1068.                 sub     ax,ax
  1069.             .endif
  1070.         .else
  1071.             mov     ax,error_vio_invalid_parms
  1072.         .endif
  1073.         ret
  1074. VioCreateLogFont endp
  1075.  
  1076. ;/***************************************************************************
  1077. ;*
  1078. ;* FUNCTION NAME = VioDeleteSetId
  1079. ;*
  1080. ;* DESCRIPTION   =
  1081. ;*
  1082. ;* INPUT         = DS:BX -> BVHINSTANCE data
  1083. ;* OUTPUT        = NONE
  1084. ;*
  1085. ;* RETURN-NORMAL = NONE
  1086. ;* RETURN-ERROR  = NONE
  1087. ;*
  1088. ;**************************************************************************/
  1089.  
  1090. VioDeleteSetId Proc NEAR
  1091.         push    ds:[bx].ppbvs_pssel ;PresSpace Sel                      ;@T52
  1092.         push    0                ;Pres Space offset
  1093.         push    [bp].parmnm1     ;LCID value pt 1
  1094.         push    [bp].parmn       ;LCID value pt 2
  1095.         call    AVIODELETESETID
  1096.         ret
  1097. VioDeleteSetId endp
  1098.  
  1099. ;/***************************************************************************
  1100. ;*
  1101. ;* FUNCTION NAME = VioQueryFonts
  1102. ;*
  1103. ;* DESCRIPTION   =
  1104. ;*
  1105. ;* INPUT         = DS:BX -> BVHINSTANCE data
  1106. ;* OUTPUT        = NONE
  1107. ;*
  1108. ;* RETURN-NORMAL = NONE
  1109. ;* RETURN-ERROR  = NONE
  1110. ;*
  1111. ;**************************************************************************/
  1112.  
  1113. VioQueryFonts Proc NEAR
  1114.         push    ds:[bx].ppbvs_pssel ;PresSpace Sel                      ;@T52
  1115.         push    0                   ;Pres Space offset
  1116.         push    [bp].parmnm1                 ;options pt 1
  1117.         push    [bp].parmn                   ;options pt 2
  1118.         push    [bp].parmnm3                 ;facename segment
  1119.         push    [bp].parmnm2                 ;facename offset
  1120.         push    [bp].parmnm5                 ;fonts pt 1
  1121.         push    [bp].parmnm4                 ;fonts pt 2
  1122.         push    [bp].parmnm7                 ;count pt 1
  1123.         push    [bp].parmnm6                 ;count pt 2
  1124.         push    [bp].parmnm9                 ;metrics pt 1
  1125.         push    [bp].parmnm8                 ;metrics pt 2
  1126.         push    [bp].(parmnm9 + 4)           ;remfonts pt 1
  1127.         push    [bp].(parmnm9 + 2)           ;remfonts pt 2
  1128.         call    AVIOQUERYFONTS
  1129.         ret
  1130. VioQueryFonts endp
  1131.  
  1132. ;/*
  1133. ;**                 Utility Subroutines
  1134. ;*/
  1135.  
  1136. ;/***************************************************************************
  1137. ;*
  1138. ;* FUNCTION NAME = _NULLCHARRECT
  1139. ;*
  1140. ;* DESCRIPTION   =
  1141. ;*
  1142. ;* INPUT         = NONE
  1143. ;* OUTPUT        = NONE
  1144. ;*
  1145. ;* RETURN-NORMAL = NONE
  1146. ;* RETURN-ERROR  = NONE
  1147. ;*
  1148. ;**************************************************************************/
  1149.  
  1150. _NULLCHARRECT Proc NEAR                                                 ;@T52
  1151.  
  1152.         Call    ClearGreDat                     ;advise...
  1153.         Call    EngineCharRect                  ;...to...
  1154.         ret                                     ;...PS
  1155. _NULLCHARRECT endp                                                      ;@T52
  1156.  
  1157. IFDEF D1348 ;BufferUpdate with dbcs bits handling
  1158.  
  1159. ;/***************************************************************************
  1160. ;*
  1161. ;* FUNCTION NAME = SetNLSbits
  1162. ;*
  1163. ;* DESCRIPTION   =
  1164. ;*
  1165. ;*        +...LVB .....................................+
  1166. ;*        .                                            .
  1167. ;*        .       +-Showed PS -+-----------------------+
  1168. ;*        . ??????|            |///////////////////////.
  1169. ;*        +-------+            |///////////////////////.
  1170. ;*        .///////|            |///////////////////////.
  1171. ;*        .///////|            +-----------------------+
  1172. ;*        .///////|            |                       .
  1173. ;*        +-------+------------+                       .
  1174. ;*        +............................................+
  1175. ;*
  1176. ;*      /// : DBCS bits in here should be handled to keep a
  1177. ;*            valid dbcs attribute at the leftmost column in
  1178. ;*            the next row.
  1179. ;*
  1180. ;*      ??? : Find the beginning of valid dbcs string.
  1181. ;*            This process has been done prior to this routine
  1182. ;*
  1183. ;* INPUT         = DS = viops_*
  1184. ;*                 ES = LVB
  1185. ;*                 DI = offset in byte
  1186. ;*                 CX = character count
  1187. ;*                 AX = don't care
  1188. ;*
  1189. ;* OUTPUT        = NONE
  1190. ;*
  1191. ;* RETURN-NORMAL = NONE
  1192. ;* RETURN-ERROR  = NONE
  1193. ;*
  1194. ;**************************************************************************/
  1195.  
  1196. Public  SetNLSbits
  1197. SetNLSbits  Proc NEAR
  1198.  
  1199.         Local_Bytes equ     2
  1200.         wLVBLimit   equ     ss:[bp][-2]
  1201.  
  1202.         enter   Local_Bytes,0           ;get storage for local variables
  1203.  
  1204.         mov     ax,ds:[viops_BufferColumnCount] ;set wLVBLimit
  1205.         mul     ds:[viops_BufferRowCount]
  1206.         mul     ds:[viops_CellByteSize]
  1207.         mov     word ptr wLVBLimit,ax
  1208.  
  1209. ;/*
  1210. ;**  Update LVB
  1211. ;*/
  1212.  
  1213.         Call    HeadBounds
  1214.         xor     dx,dx                   ;clear the char counter
  1215.         .while  ncxz
  1216.             mov     al,es:[si]          ;get a code point in the cell
  1217.             add     si,4                ;skip attr#0,1,2
  1218.             mov     ah,es:[si-2]        ;get character set bits (attr#2)
  1219.             dec     cx                  ;adjust the loop counter (CX)
  1220.             inc     dx                  ;increment the char counter (DX)
  1221.  
  1222.             call    CheckDBCS
  1223.             .if     c                   ;if char have DBCS leading byte
  1224.                 .if     < dx gt 1 >     ;SBCS Char Counter must be GT 1.
  1225.                     dec     dx          ;Adjust
  1226.                     call    Writes      ;Write the leading Hankaku String.
  1227.                 .endif
  1228.  
  1229.                 xor     dx,dx           ;clear the char counter (DX)
  1230.                 .if     ncxz            ;& cx > 0
  1231.                     add     si,4
  1232.                     dec     cx          ;adjust the loop counter (CX)
  1233.                     call    PutDBCSs    ;write dbcs into LVB
  1234.                 .else                                                   ;@A21
  1235.                     call    PutDBCSinEnds                               ;@A21
  1236.                 .endif
  1237.             .endif                      ;End of DBCS Case
  1238.         .endwhile
  1239.  
  1240.         .if     < dx ne 0 >
  1241.             push    di
  1242.             call    Writes              ;Write SBCS char to LVB
  1243.             pop     di
  1244.         .endif
  1245.  
  1246.         leave
  1247.         ret
  1248. SetNLSbits  endp
  1249.  
  1250. ;/*
  1251. ;** OverWriting Handling
  1252. ;** ES:DI - LVB
  1253. ;*/
  1254.  
  1255. ;/***************************************************************************
  1256. ;*
  1257. ;* FUNCTION NAME = HeadBounds
  1258. ;*
  1259. ;* DESCRIPTION   =
  1260. ;*
  1261. ;* INPUT         = NONE
  1262. ;* OUTPUT        = NONE
  1263. ;*
  1264. ;* RETURN-NORMAL = NONE
  1265. ;* RETURN-ERROR  = NONE
  1266. ;*
  1267. ;**************************************************************************/
  1268.  
  1269. public  HeadBounds
  1270. HeadBounds Proc NEAR                        ;OverWriting of DBCS bisected
  1271.                                             ;leading in the biginning.
  1272.         cmp     di,4                        ;check start of screen or not ?
  1273.         .if     ae
  1274.             test    byte ptr es:[di+3],TrailByteFlag ;DBCS 2nd(trailing) ?
  1275.             .if     nz
  1276.                 mov     byte ptr es:[di-4],20h  ;place a space
  1277.                 and     byte ptr es:[di-1], Not (DBCSFlag+TrailByteFlag) ;off DBCS bits
  1278.             .endif
  1279.         .endif
  1280.         ret
  1281. HeadBounds endp
  1282.  
  1283. ;/***************************************************************************
  1284. ;*
  1285. ;* FUNCTION NAME = HeadBounds
  1286. ;*
  1287. ;* DESCRIPTION   = Set DBCS bits(DBCS bit and DBCS trailing
  1288. ;*                 bit)
  1289. ;*
  1290. ;* INPUT         = ES:DI = LVB
  1291. ;* OUTPUT        = NONE
  1292. ;*
  1293. ;* RETURN-NORMAL = NONE
  1294. ;* RETURN-ERROR  = NONE
  1295. ;*
  1296. ;**************************************************************************/
  1297.  
  1298. public  PutDBCSs
  1299. PutDBCSs Proc
  1300.  
  1301. ;/*
  1302. ;** Set dbcs bit(s).
  1303. ;** Copy the attr of leading byte to that of trailing.
  1304. ;*/
  1305.  
  1306.                                                       ;/set dbcs leading byte bit
  1307.         and     byte ptr es:[di+3], not TrailByteFlag ;set dbcs trailing off
  1308.         or      byte ptr es:[di+3], DBCSFlag          ;set dbcs leading bit on
  1309.  
  1310.                                                       ;/set dbcs traling byte bit
  1311.         or      byte ptr es:[di+7], DBCSFlag+TrailByteFlag ;set dbcs bit and
  1312.                                                       ;dbcs trailing bit on
  1313.         add     di,8
  1314.  
  1315.         ret
  1316. PutDBCSs endp
  1317.  
  1318. ;/***************************************************************************
  1319. ;*
  1320. ;* FUNCTION NAME = TailBounds
  1321. ;*
  1322. ;* DESCRIPTION   =
  1323. ;*
  1324. ;* INPUT         = NONE
  1325. ;* OUTPUT        = NONE
  1326. ;*
  1327. ;* RETURN-NORMAL = NONE
  1328. ;* RETURN-ERROR  = NONE
  1329. ;*
  1330. ;**************************************************************************/
  1331.  
  1332. public  TailBounds
  1333. TailBounds PROC NEAR                    ;Overwriting of Tail DBCS Widow
  1334.         cmp     di, word ptr wLVBLimit  ;check end of lvb or not ?
  1335.         .if     b
  1336.             test    byte ptr es:[di+3],TrailByteFlag ; Target Tail+1 is dbcs 2nd ?
  1337.             .if     nz
  1338.                 mov     byte ptr es:[di],20h    ;place space to avoid a wrong
  1339.                                                 ;display output of dbcs after
  1340.                                                 ;the specified rectangle.
  1341.                 and     byte ptr es:[di+3], Not (DBCSFlag+TrailByteFlag) ;off DBCS
  1342.                 add     di,4
  1343.             .endif
  1344.         .endif
  1345.         ret
  1346. TailBounds ENDP
  1347.  
  1348. ;/***************************************************************************
  1349. ;*
  1350. ;* FUNCTION NAME = PutDBCSinEnds
  1351. ;*
  1352. ;* DESCRIPTION   = Set dbcs bit(s).
  1353. ;*                 Copy the attr of leading byte to that of trailing.
  1354. ;*
  1355. ;* INPUT         = NONE
  1356. ;* OUTPUT        = NONE
  1357. ;*
  1358. ;* RETURN-NORMAL = NONE
  1359. ;* RETURN-ERROR  = NONE
  1360. ;*
  1361. ;**************************************************************************/
  1362.  
  1363. public  PutDBCSinEnds
  1364. PutDBCSinEnds   Proc
  1365.  
  1366.         add     di,4
  1367.  
  1368.         cmp     di, word ptr wLVBLimit                ;check end of lvb or not ?
  1369.         .if     b
  1370.                                                       ;/set dbcs leading byte bit
  1371.             and     byte ptr es:[di-1], not TrailByteFlag  ;set dbcs trailing off
  1372.             or      byte ptr es:[di-1], DBCSFlag      ;set dbcs leading bit on
  1373.                                                       ;/set dbcs traling byte bit
  1374.             or      byte ptr es:[di+3], DBCSFlag+TrailByteFlag ;set dbcs bit and
  1375.                                                       ;dbcs trailing bit on
  1376.         .endif
  1377.  
  1378.         ret
  1379. PutDBCSinEnds   endp
  1380.  
  1381. ;/***************************************************************************
  1382. ;*
  1383. ;* FUNCTION NAME = Writes
  1384. ;*
  1385. ;* DESCRIPTION   = Set SBCS bit
  1386. ;*
  1387. ;* INPUT         = ES:DI = LVB
  1388. ;*                 DX = the count for SBCS characters
  1389. ;*
  1390. ;* OUTPUT        = NONE
  1391. ;*
  1392. ;* RETURN-NORMAL = NONE
  1393. ;* RETURN-ERROR  = NONE
  1394. ;*
  1395. ;**************************************************************************/
  1396.  
  1397. Public  Writes
  1398. Writes  PROC                                ;SBCS write routine
  1399.         push    cx
  1400.         mov     cx,dx                       ;the number of SBCS characters
  1401.         .while  ncxz
  1402.  
  1403.             and     byte ptr es:[di+3], not (DBCSFlag+TrailByteFlag) ;off dbcs bits
  1404.             add     di,ds:[viops_CellByteSize]
  1405.             dec     cx
  1406.         .endwhile
  1407.         pop     cx
  1408.         ret
  1409. Writes  ENDP
  1410.  
  1411. ;/***************************************************************************
  1412. ;*
  1413. ;* FUNCTION NAME = CheckDBCS
  1414. ;*
  1415. ;* DESCRIPTION   = Check if input code point is DBCS leading
  1416. ;*                 byte or not
  1417. ;*
  1418. ;* INPUT         = AL = Checked character        CF = 0 if SBCS
  1419. ;*                      code point                  = 1 if DBCS leading
  1420. ;*                 AH = attr #2
  1421. ;*
  1422. ;* OUTPUT        = NONE
  1423. ;*
  1424. ;* RETURN-NORMAL = NONE
  1425. ;* RETURN-ERROR  = NONE
  1426. ;*
  1427. ;**************************************************************************/
  1428.  
  1429. Public  CheckDBCS
  1430. CheckDBCS PROC  NEAR
  1431.         push    ds
  1432.         push    si
  1433.         push    cx
  1434.         push    dx
  1435.         push    bx
  1436.         xor     bh,bh
  1437.         mov     bl,ah
  1438.         and     bl,lcid_mask
  1439.         xchg    bx,ax
  1440.         mov     dx,size DBCSENVINFO
  1441.         mul     dx
  1442.         xchg    bx,ax
  1443.  
  1444.         clc
  1445.         mov     cx,DBCSEvBufSiz/2       ; set loop count
  1446.  
  1447.         lds     si,ds:[viops_lpNLSExt]  ; ds:si -> dbcs env. buffer
  1448.  
  1449.         mov     dx,ds:[bx+si]
  1450. DBCS_LOOP:
  1451.         cmp     dx,0
  1452.         jz      DBCS_END
  1453.         cmp     dl,al                   ; comp start value
  1454.         ja      DBCS_END                ; smaller than lower limit
  1455.         cmp     al,dh                   ; comp stop value
  1456.         jbe     DBCS_OK                 ; in range
  1457. DBCS_NO:
  1458.         inc     si                      ; see next vecter
  1459.         inc     si
  1460.         mov     dx,ds:[si]
  1461.         loop    DBCS_LOOP
  1462. DBCS_OK:
  1463.         stc
  1464. DBCS_END:
  1465.         pop     bx
  1466.         pop     dx
  1467.         pop     cx
  1468.         pop     si
  1469.         pop     ds
  1470.         ret
  1471. CheckDBCS endp
  1472.  
  1473. ClearSel  proc
  1474.         push    bx
  1475.         push    cx
  1476.         push    di
  1477.         push    es
  1478.  
  1479.         lsl     bx,ax
  1480.         inc     bx
  1481.         shr     bx,1
  1482.         mov     cx,bx
  1483.         mov     es,ax
  1484.         xor     ax,ax
  1485.         xor     di,di
  1486.  
  1487.         rep     stosw
  1488.         pop     es
  1489.         pop     di
  1490.         pop     cx
  1491.         pop     bx
  1492.         ret
  1493. ClearSel  endp
  1494.  
  1495. ENDIF ;D1348
  1496.  
  1497. avio3seg ends
  1498.         end
  1499.  
  1500.