;       SCCSID = @(#)d_sctrcd.asm	6.1 91/02/15
;      SCCSID = @(#)d_sctrcd.asm	6.2 90/01/22
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************
;***  d_sctrcd.asm - API stub routine DosSetCtryCode
;
;	Member of API library
;	Karl Schulmeister
;	Copyright MicroSoft Corporation, 1986
;	28-May-1986
;
;	library routine for API simulator
;
;	Called from dos 2.x,3.x compatible dos 5.x applications
;
;	Special Information
;		none
;
;	Modification History
;	26Jun86 (billme): minor rewrite
;
;	06-Jan-87 (billme): Replace initial pushes and final pops
;	with calls to __api_begin and __api_end resp.  This will
;	reduce the size of FAPI and allow support for signals.
;

.xlist
include struc.inc
include nlsapi.inc

	EXTRN	__api_begin:near
	EXTRN	__api_end:near
.list

;***	DOSSETCTRYCODE - stub to emulate DOSSETCTRYCODE function call
;
;	simulates DOS 5.0 call from DOS 2.x,3.x environment
;
;	errorcode = unsigned far pascal DOSSETCTRYCODE (ptrCtryCode)
;
;
;	ENTRY:
;		- ptrCtryCode = pointer to New Country Code DWORD
;
;	RETURN:
;		AX - 0 (no error)
;
;	EXIT:
;
;	USES:
;		AX
;
;	Pseudo Code:
;		save registers
;		load AX:BP with New Country Code
;		Set Current Country Code to New Country Code
;		restore registers
;		return
;
;	WARNING:
;		DOES NOT SET THE SYSTEMs COUNTRY CODE since the PCDOS
;		COUNTRY CODE IS A WORD!
;
;	EFFECTS:
;		none
;

CtryCode_Stack	struc
	CBp	dw	?
	CIp	dw	?
	CCs	dw	?
	CCode	dd	?
CtryCode_Stack	   ends


DGROUP	group	_DATA

_TEXT	segment word public 'CODE'
_TEXT	ends

_DATA	segment word public 'DATA'
_DATA	ends

_DATA	segment
	EXTRN	_CurrCtryCd:DWORD
_DATA	ends

_TEXT	segment

public	DOSSETCTRYCODE
DOSSETCTRYCODE	  proc	  far
	assume	cs:_TEXT

	call	__api_begin	; init bp and save bp,ds,bx,cx,dx,si,di,es
				; required to save: bp,ds,bx + si

	lds	si, [si].CCode		; (DS:si) <- ptr to New Country Code
	mov	bx, ds:[si]		; (si:BX) <- New Country Code
	mov	si, ds:[si+2]

	mov	ax,_DATA		; Establish addresibility of Local
	mov	ds,ax			;   DATA area
	assume	ds:_DATA
					; Current Ctry Code <- New Ctry Code
	mov	word ptr [_CurrCtryCd], bx
	mov	word ptr [_CurrCtryCd+2], si

	xor	ax,ax


	call	__api_end	; check sigs & restore es,di,si,dx,cx,bx,ds,bp

	ret	4

DOSSETCTRYCODE endp

_TEXT	ENDS
	END
