;       SCCSID = @(#)bvfgmode.asm	6.1 90/11/16
;SCCSID = @(#)bvfgmode.asm	6.3 90/01/23
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************
	PAGE	58,132
	TITLE	BvfGMode.Asm -- Base Video Subsystem GetMode Routine

;/*********************** START OF SPECIFICATIONS ***********************/
;/*									*/
;/* SOURCE FILE NAME:	 BvsGMode.Asm					*/
;/*									*/
;/* DESCRIPTIVE NAME:	 BVS GetMode Routine				*/
;/*									*/
;/* COPYRIGHT:	 na							*/
;/*									*/
;/* STATUS:	 na							*/
;/*									*/
;/* NOTES:	 Executes on level 3					*/
;/*									*/
;/*    DEPENDENCIES:	None						*/
;/*									*/
;/*    RESTRICTIONS:	None						*/
;/*									*/
;/*    PATCH LABEL:	 na						*/
;/*									*/
;/* ENTRY POINTS: BvsGetMode						*/
;/*									*/
;/* EXTERNAL REFERENCES: None						*/
;/************************ END OF SPECIFICATIONS ************************/

	.xlist
	INCLUDE bvfcb.inc		;BVS Data Structures
	INCLUDE error2.inc		;CP/DOS Error Codes
	INCLUDE struc.inc		;Structured Macros
	.list

	extrn	BVSROUT:NEAR

BVS3SEG SEGMENT BYTE PUBLIC 'CODE'
	ASSUME	CS:BVS3SEG,DS:NOTHING

VIOGETMODE proc far
	public	VIOGETMODE
	pushi	<offset CS:BvsGetMode>
	call	BVSROUT
	ret	6			;2 words + VioHandle
VIOGETMODE endp

;/*********************** START OF SPECIFICATIONS ***********************/
;/*									*/
;/* SUBROUTINE NAME:  BvsGetMode					*/
;/*									*/
;/* DESCRIPTIVE NAME:  Base Video Subsystem Get Mode			*/
;/*									*/
;/* FUNCTION:  Returns the attributes of the current display mode for	*/
;/*	       the Base Video Subsystem 				*/
;/*									*/
;/* NOTES:  Executes on Level 3 					*/
;/*									*/
;/* ENTRY POINT:  BvsGetMode						*/
;/*   LINKAGE:	Call BvsGetMode from BVSMAIN				*/
;/*									*/
;/* INPUT:  StackFrame and Registers (see BVSMAIN)			*/
;/*	parmn	= Offset of mode data block				*/
;/*	parmnm1 = Selector of mode data block				*/
;/*									*/
;/* EXIT-NORMAL:  AX = 0						*/
;/*		  PVB selector/offset in user area plus LDT entry	*/
;/*		  Rows, Columns, Type, and Color to user area		*/
;/*									*/
;/* EXIT-ERROR: Invalid ptr to Parameter Block				*/
;/*									*/
;/* EFFECTS:  None							*/
;/*									*/
;/* INTERNAL REFERENCES:  BVSCBsg					*/
;/*   ROUTINES:  None							*/
;/*									*/
;/* EXTERNAL REFERENCES:  None						*/
;/*   ROUTINES:  None							*/
;/*									*/
;/************************ END OF SPECIFICATIONS ************************/

;Bgnsub BvsGetMode
;: Copy Mode Data from BVSCBsg to user parmlist
;: Set AX=0 for return code
;Endsub

BvsGetMode PROC NEAR
;	PUBLIC	BvsGetMode

	mov	ax,ERROR_VIO_INVALID_LENGTH
	les	di,dword ptr [bp].parmn ;Get user ptr to mode data
	mov	cx,es:[di].mode_datalen ;Get length of mode data
	.if	<cx a 1>
	    mov     si,bvs_mdlen	;Get source ptr to mode data

	    mov     ax,cx
	    .if     <al a <size modedataext>> ;@S25
		mov	al,mode_attrformat ;@S25
	    .endif			;@S25

	    push    di
	    sub     al,size mode_datalen
	    .if     <ns>
		movsw
	    .endif

	    sub     al,size mode_type
	    .if     <ns>
		movsb
	    .endif

	    sub     al,size mode_colors
	    .if     <ns>
		movsb
	    .endif

	    sub     al,size mode_cols
	    .if     <ns>
		movsw
	    .endif

	    sub     al,size mode_rows
	    .if     <ns>
		movsw
	    .endif

	    sub     al,size mode_gcols
	    .if     <ns>
		movsw
	    .endif

	    sub     al,size mode_grows
	    .if     <ns>
		movsw
	    .endif

	    sub     al,size mode_attrformat
	    .if     <ns>
		movsb
	    .endif

	    sub     al,size mode_attrbytes
	    .if     <ns>
		movsb
	    .endif

	    sub     al,size mode_bufaddr
	    .if     <ns>
		movsw
		movsw
	    .endif

	    sub     al,size mode_bufsize
	    .if     <ns>
		movsw
		movsw
	    .endif

	    sub     al,size mode_fullbufsz
	    .if     <ns>
		movsw
		movsw
	    .endif

	    sub     al,size mode_partbufsz
	    .if     <ns>
		movsw
		movsw
	    .endif

	    sub     al,size mode_extdata
	    .if     <ns>
		movsw
		movsw
	    .endif

	    mov     ax,di
	    pop     di
	    sub     ax,di
	    .if     <al a 2>		;More than just a length request
		stosw			;Update length in Mode data
	    .endif

	    sub     ax,ax		;Set good return code
	.endif
	RET				;Return to caller
BvsGetMode ENDP

BVS3SEG ENDS
	END

;@@A = 12/14/88 STJ, BvsGetMode rewritten, P3156
;@S25 = 08/18/89 STJ, Use 1.0 length as default for GetXXXX calls, B706860
