;       SCCSID = @(#)nlsinit.asm	6.1 90/11/17
;	SCCSID = @(#)nlsinit.asm	6.2 90/06/15
;	SCCSID = @(#)nlsinit.asm	6.2 90/06/15
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************
SUBTTL NLS_Init Routine
PAGE
;/******* START OF SPECIFICATION ********************************/
;/*								*/
;/* SUBROUTINE	NAME: NLS_Init					*/
;/*								*/
;/* DESCRIPTIVE NAME: NLS Dynamic Link Library Initialization	*/
;/*								*/
;/* FUNCTION: Initialize NLS.DLL at initial load time.		*/
;/*	      Keep the GDT selector which is returned by	*/
;/*	      DosGetShrSeg into global data area.  Also 	*/
;/*	      get the location of COUNTRY.SYS file from 	*/
;/*	      CDIB.						*/
;/*								*/
;/* NOTES: New Routine for 1.2 Release. 			*/
;/*								*/
;/* ENTRY POINT: NLS_Init					*/
;/*   LINKAGE:							*/
;/*								*/
;/* INPUT:	 None						*/
;/*								*/
;/*								*/
;/* EXIT-NORMAL:						*/
;/*		 Return AX not= 0				*/
;/*								*/
;/* EXIT-ERROR: 						*/
;/*		 Return AX = 0					*/
;/*								*/
;/* EFFECTS:							*/
;/*								*/
;/*								*/
;/* INTERNAL REFERENCES:					*/
;/*	   ROUTINES:						*/
;/*	     None						*/
;/*								*/
;/* EXTERNAL REFERENCES:					*/
;/*	   ROUTINES:						*/
;/*	     DOSGETSHRSEG - Get CDIB Shared Segment		*/
;/*								*/
;/*								*/
;/************ END OF SOURCE FILE SPECIFICATIONS ****************/
 PAGE
.286p
.xlist
include cdib.inc
include dc1segs.inc						; DCR 704
.list
extrn	DOSGETSHRSEG:far

INITN_TEXT   EQU    <CODE16>					; DCR 704
; DGROUP  group   _DATA 					; DCR 704
SHRDATA   segment
SHRDATA   ends
SHRDATA   segment
OFF_COUNTRY	equ	4
cdib_loc	db	'\SHAREMEM\DOS\CDIB',0

public	_gGDT_sel
_gGDT_sel	label	word
		dw	0h

public	_gFile
_gFile		label	byte
		db	260 dup(0)
SHRDATA   ends

INITN_TEXT   segment
	assume	cs:INITN_TEXT,ds:SHRDATA			  ; DCR 704
		PUBLIC	NLS_Init				; DCR 704
NLS_Init	PROC	FAR

;	int	3

	push	ds			; Save Registers	; DCR 704
	push	es						; DCR 704
	push	bx						; DCR 704
	push	dx						; DCR 704
	push	di						; DCR 704
	push	si						; DCR 704
	push	SHRDATA 					  ; DCR 704
	pop	ds						; DCR 704

;
; CALL DOSGETSHARESEG - get CDIB GDT selector and store it into gGDT_sel
;
	push	ds			; cdib_loc
	lea	ax,cdib_loc		; make ax be offset of cdib_loc
	push	ax
	push	ds			; gGDT_sel
	lea	ax,word ptr _gGDT_sel	; make ax be offset of gGDT_sel
	push	ax			;
	call	DOSGETSHRSEG		; Get GDT selector


	cmp	ax,0			; If no error
	jz	set_gFile		; go to set gFile
	xor	ax,ax			; else set ax = 0
	jmp	error_init		; and go to error Initialization


set_gFile:
	mov	es,_gGDT_sel		; es;[di] points to CDIB's
	mov	di,OFF_COUNTRY		; COUNTRY offset
	mov	di,word ptr es:[di]	; es:[bx] points to COUNTRY.SYS
	lea	bx,es:[di].CDIB_ct_filename  ; file path/name in CDIB
	lea	si,word ptr _gFile	; ds:[si] points gFile

file_loop:
	mov	dl,byte ptr es:[bx]	; copy COUNTRY.SYS path/file name
	cmp	dl,0			; into gFile until encounting 0
	jz	end_file		;
					;
	mov	byte ptr ds:[si],dl	;
	inc	bx			; increment the pointer for CDIB
	inc	si			; increment the pointer for gFile
	jmp	file_loop		;
					;
end_file:				;
	mov	byte ptr ds:[si],0	; Insert 0 at the end of gFIle
	mov	ax,-1			; Set ax to FFh
error_init:
	pop	si			;Restore registers	; DCR 704
	pop	di						; DCR 704
	pop	dx						; DCR 704
	pop	bx						; DCR 704
	pop	es						; DCR 704
	pop	ds						; DCR 704
	RET
NLS_Init  endp
INITN_TEXT  ends
	end			; DLL load time Initialization Routine DCR 704
;	end	NLS_Init	; DLL load time Initialization Routine DCR 704
;**************************************************************************
