home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / IDHMODE.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  12KB  |  282 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   IDHMODE.Asm -- Windowable Device Handler Mode Routines
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = IDHMODE.Asm
  18. ;*
  19. ;* DESCRIPTIVE NAME = Windowable Device Handler Mode Routines 
  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    GetMode, SetMode
  30. ;*
  31. ;* NOTES        NONE
  32. ;*             
  33. ;* STRUCTURES   NONE
  34. ;*
  35. ;* EXTERNAL REFERENCES  NONE
  36. ;*
  37. ;* EXTERNAL FUNCTIONS
  38. ;*
  39. ;*              NONE
  40. ;*
  41. ;* CHANGE ACTIVIY =
  42. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  43. ;*   --------  ---------- -----   --------------------------------------
  44. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  45. ;*   08/18/89  @S25       B706860 STJ, Use 1.0 length as default for GetXXXX         
  46. ;*                                calls
  47. ;****************************************************************************/
  48.  
  49.         .xlist
  50.         INCLUDE idhequ.inc              ;Install Device Handler Equates
  51.         INCLUDE bvsparms.inc            ;BVS Parameter Equates
  52.         INCLUDE error2.inc              ;CP/DOS Error Codes
  53.         INCLUDE struc.inc               ;Structured Macros
  54.         .list
  55.  
  56.         extrn   RegSave:NEAR
  57.         extrn   RegRest:NEAR
  58.         extrn   SetCurPos:FAR
  59.  
  60. R2CSEG  SEGMENT BYTE PUBLIC 'CODE'
  61.         ASSUME  CS:R2CSEG
  62.  
  63. ;/****************************************************************************
  64. ;*                                                                     
  65. ;*  SUBROUTINE NAME: GetMode                                           
  66. ;*                                                                     
  67. ;*  DESCRIPTIVE NAME: Get current video mode setting                   
  68. ;*                                                                     
  69. ;*  FUNCTION: GetMode is called by BVS to get the current mode setting.
  70. ;*            If the request specifies hardware and the hardware is    
  71. ;*            readable, the actual hardware setting will be read and   
  72. ;*            returned.  Otherwise the returned information will be    
  73. ;*            taken from the environment buffer, if it has been passed.
  74. ;*                                                                     
  75. ;*  ENTRY POINT: GetMode                                               
  76. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 271 )  
  77. ;*                                                                     
  78. ;*  INPUT: (Passed on stack)                                           
  79. ;*             FAR *Environment ( Environment buffer for the session ) 
  80. ;*             FAR *ParmBlock                                          
  81. ;*                     USHORT Length = length of this packet           
  82. ;*                     USHORT Flags  = 0 - Environment buffer only     
  83. ;*                                     1 - Hardware also               
  84. ;*                     VIOMODEINFO FAR *ModeDataPTR                    
  85. ;*             ULONG Function ( Call vector table entry = 271 )        
  86. ;*         (Referenced)                                                
  87. ;*             Modes[] (global data - table of supported video modes ) 
  88. ;*                                                                     
  89. ;*  EXIT-NORMAL: AX = 0                                                
  90. ;*               Current mode setting is returned                      
  91. ;*                                                                     
  92. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS                           
  93. ;*                                                                     
  94. ;*  EFFECTS: If hardware specified and hardware is readable, the       
  95. ;*           environment buffer is updated, if passed.                 
  96. ;*                                                                     
  97. ;*  INTERNAL REFERENCES:                                               
  98. ;*    ROUTINES: NONE                                                   
  99. ;*                                                                     
  100. ;*  EXTERNAL REFERENCES:                                               
  101. ;*    ROUTINES: NONE                                                   
  102. ;*                                                                     
  103. ;****************************************************************************/
  104.  
  105. GetMode PROC    FAR
  106.         public  GetMode
  107.         Call    RegSave
  108.  
  109.         mov     ax,ERROR_VIO_INVALID_LENGTH
  110.         .if     <[si].vp_parmlength eq 8> and
  111.         les     di,dword ptr [si].vp_offset ;Get address of mode data
  112.         lds     si,dword ptr [bp].stk_envblock ;Get environment block
  113.         add     si,[si].env_modeoffset  ;Get offset of mode data
  114.         mov     cx,es:[di].mode_datalen ;Get length of mode data
  115.         .if     <cx a 1>
  116.  
  117.             mov     ax,cx
  118.             .if     <al a <size modedata>> ;@S25
  119.                 mov     al,mode_attrformat ;@S25
  120.             .endif                      ;@S25
  121.  
  122.             push    di
  123.             sub     al,size mode_datalen
  124.             .if     <ns>
  125.                 movsw
  126.             .endif
  127.  
  128.             sub     al,size mode_type
  129.             .if     <ns>
  130.                 movsb
  131.             .endif
  132.  
  133.             sub     al,size mode_colors
  134.             .if     <ns>
  135.                 movsb
  136.             .endif
  137.  
  138.             sub     al,size mode_cols
  139.             .if     <ns>
  140.                 movsw
  141.             .endif
  142.  
  143.             sub     al,size mode_rows
  144.             .if     <ns>
  145.                 movsw
  146.             .endif
  147.  
  148.             sub     al,size mode_gcols
  149.             .if     <ns>
  150.                 movsw
  151.             .endif
  152.  
  153.             sub     al,size mode_grows
  154.             .if     <ns>
  155.                 movsw
  156.             .endif
  157.  
  158.             sub     al,size mode_attrformat
  159.             .if     <ns>
  160.                 movsb
  161.             .endif
  162.  
  163.             sub     al,size mode_attrbytes
  164.             .if     <ns>
  165.                 movsb
  166.             .endif
  167.  
  168.             sub     al,size mode_bufaddr
  169.             .if     <ns>
  170.                 movsw
  171.                 movsw
  172.             .endif
  173.  
  174.             sub     al,size mode_bufsize
  175.             .if     <ns>
  176.                 movsw
  177.                 movsw
  178.             .endif
  179.  
  180.             sub     al,size mode_fullbufsz
  181.             .if     <ns>
  182.                 movsw
  183.                 movsw
  184.             .endif
  185.  
  186.             sub     al,size mode_partbufsz
  187.             .if     <ns>
  188.                 movsw
  189.                 movsw
  190.             .endif
  191.  
  192.             sub     al,size mode_extdata
  193.             .if     <ns>
  194.                 movsw
  195.                 movsw
  196.             .endif
  197.  
  198.             mov     ax,di
  199.             pop     di
  200.             sub     ax,di
  201.             .if     <al a 2>            ;More than just a length request
  202.                 stosw                   ;Update length in Mode data
  203.             .endif
  204.  
  205.             sub     ax,ax               ;Set good return code
  206.         .endif
  207.  
  208.         Call    RegRest
  209.         ret     12
  210. GetMode ENDP
  211.  
  212. ;/****************************************************************************
  213. ;*                                                                     
  214. ;*  SUBROUTINE NAME: SetMode                                           
  215. ;*                                                                     
  216. ;*  DESCRIPTIVE NAME: Set video mode                                   
  217. ;*                                                                     
  218. ;*  FUNCTION: SetMode is called by BVS to set the video mode.          
  219. ;*            If the request specifies hardware, the hardware and the  
  220. ;*            environment buffer, if passed, will be updated.          
  221. ;*            Otherwise just the environment buffer, if passed, will   
  222. ;*            be updated.                                              
  223. ;*                                                                     
  224. ;*  ENTRY POINT: SetMode                                               
  225. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 272 )  
  226. ;*                                                                     
  227. ;*  INPUT: (Passed on stack)                                           
  228. ;*             FAR *Environment ( Environment buffer for the session ) 
  229. ;*             FAR *ParmBlock                                          
  230. ;*                     USHORT Length = length of this packet           
  231. ;*                     USHORT Flags  = 0 - Environment buffer only     
  232. ;*                                     1 - Hardware also               
  233. ;*                     VIOMODEINFO FAR *ModeDataPTR                    
  234. ;*             ULONG Function ( Call vector table entry = 272 )        
  235. ;*         (Referenced)                                                
  236. ;*             Modes[] (global data - table of supported video modes ) 
  237. ;*                                                                     
  238. ;*  EXIT-NORMAL: AX = 0                                                
  239. ;*               Video mode is set                                     
  240. ;*                                                                     
  241. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS                           
  242. ;*                                                                     
  243. ;*  INTERNAL REFERENCES:                                               
  244. ;*    ROUTINES: NONE                                                   
  245. ;*                                                                     
  246. ;*  EXTERNAL REFERENCES:                                               
  247. ;*    ROUTINES: NONE                                                   
  248. ;*                                                                     
  249. ;****************************************************************************/
  250.  
  251. SetMode PROC    FAR
  252.         public  SetMode
  253.         Call    RegSave
  254.  
  255.         mov     ax,ERROR_VIO_INVALID_LENGTH
  256.         .if     <[si].vp_parmlength eq 8> and
  257.         lds     si,dword ptr [si].vp_offset ;Get address of mode data
  258.         mov     cx,[si].mode_datalen    ;Get length of mode data
  259.         .if     <cx ae 3> and
  260.         mov     ax,ERROR_VIO_MODE       ;Preset mode error
  261.         test    [si].mode_type,mode_f_graphics
  262.         .if     <z>                     ;Mode type = Text
  263.             .if     <cx b mode_cols+2> or
  264.             .if     <[si].mode_cols eq 80> ;80-column modes only
  265.                 .if     <cx b mode_rows+2> or
  266.                 .if     <[si].mode_rows eq 25> ;25-row modes only
  267.                     mov     es:[di].env_row,bx
  268.                     mov     es:[di].env_col,bx
  269.                     Call    SetCurPos   ;Home the cursor
  270.                     sub     ax,ax
  271.                 .endif
  272.             .endif
  273.         .endif
  274.  
  275.         Call    RegRest
  276.         ret     12
  277. SetMode ENDP
  278.  
  279. R2CSEG  ENDS
  280.         END
  281.  
  282.