		include	vkwin.inc
		include	vkoem.inc
memM            =       1
?WIN		=	0
?PLM		=	0
		include	cmacros.inc
		sBegin	DATA
		public	_CTable
_CTable		label	byte
CyrTable	label	byte
	; AsciiTable
	DB	VK_CANCEL ,	03h,	03h,	57
	DB	VK_BACK   ,	08h,	08h,	57
	DB	VK_TAB    ,	09h,	-1,   	57
	DB	VK_RETURN ,	0dh,	0dh,	57
	DB	VK_ESCAPE ,	01bh,	01bh,	57
	DB	VK_SPACE  ,	' ',  	' ',  	57
	DB	VK_EXECUTE,	0dh,	0dh,	57
	DB	VK_0      ,	'0',  	')',  	11
	DB	VK_1      ,	'1',  	'!',  	 2
	DB	VK_2      ,	'2',  	'"',  	 3
	DB	VK_3      ,	'3',  	167,  	 4
	DB	VK_4      ,	'4',  	'$',  	 5
	DB	VK_5      ,	'5',  	':',	 6
	DB	VK_6      ,	'6',  	',',  	 7
	DB	VK_7      ,	'7',  	'.',  	 8
	DB	VK_8      ,	'8',  	';',  	 9
	DB	VK_9      ,	'9',  	'(',  	10
	DB	VK_A      ,	0f4h,  	0d4h,  	30
	DB	VK_B      ,	0e8h,  	0c8h,  	48
	DB	VK_C      ,	0f1h,  	0d1h,  	46
	DB	VK_D      ,	0e2h,  	0c2h,  	32
	DB	VK_E      ,	0f3h,  	0d3h,  	18
	DB	VK_F      ,	0e0h,  	0c0h,  	33
	DB	VK_G      ,	0efh,  	0cfh,  	34
	DB	VK_H      ,	0f0h,  	0d0h,  	35
	DB	VK_I      ,	0f8h,  	0d8h,  	23
	DB	VK_J      ,	0eeh,  	0ceh,  	36
	DB	VK_K      ,	0ebh,  	0cbh,  	37
	DB	VK_L      ,	0e4h,  	0c4h,  	38
	DB	VK_M      ,	0fch,  	0dch,  	50
	DB	VK_N      ,	0f2h,  	0d2h,  	49
	DB	VK_O      ,	0f9h,  	0d9h,  	24
	DB	VK_P      ,	0e7h,  	0c7h,  	25
	DB	VK_Q      ,	0e9h,  	0c9h,  	16
	DB	VK_R      ,	0eah,  	0cah,  	19
	DB	VK_S      ,	0fbh,  	0dbh,  	31
	DB	VK_T      ,	0e5h,  	0c5h,  	20
	DB	VK_U      ,	0e3h,  	0c3h,  	22
	DB	VK_V      ,	0ech,  	0cch,  	47
	DB	VK_W      ,	0f6h,  	0d6h,  	17
	DB	VK_X      ,	0f7h,  	0d7h,  	45
	DB	VK_Y      ,	0edh,  	0cdh,  	21
	DB	VK_Z      ,	0ffh,  	0dfh,  	44
	DB	VK_NUMPAD0,	'0',  	'0',  	57
	DB	VK_NUMPAD1,	'1',  	'1',  	57
	DB	VK_NUMPAD2,	'2',  	'2',  	57
	DB	VK_NUMPAD3,	'3',  	'3',  	57
	DB	VK_NUMPAD4,	'4',  	'4',  	57
	DB	VK_NUMPAD5,	'5',  	'5',  	57
	DB	VK_NUMPAD6,	'6',  	'6',  	57
	DB	VK_NUMPAD7,	'7',  	'7',  	57
	DB	VK_NUMPAD8,	'8',  	'8',  	57
	DB	VK_NUMPAD9,	'9',  	'9',  	57
	DB	VK_MULTIPLY,	'*',  	'*',  	57
	DB	VK_SUBTRACT,	'-',  	'-',  	57
	DB	VK_ADD    ,	'+',  	'+',  	57
        DB      VK_DECIMAL,     0feh,   0deh,   52      ; 57
	DB	VK_DIVIDE ,	'/',  	'/',  	57
        DB      VK_OEM_1    ,   0e6h,   0c6h,   39      ; 57
	DB	VK_OEM_2    ,	'/',  	'?',  	53
        DB      VK_OEM_7    ,   0fdh,   0ddh,   40      ; 57
        DB      VK_OEM_4    ,   0f5h,   0d5h,   26      ; 57
	DB	VK_OEM_5    ,	'\',  	'|',  	43
        DB      VK_OEM_6    ,   0fah,   0dah,   27      ; 57
;	DB	VK_OEM_3    ,	'`',  	'~',  	41
 	DB	VK_OEM_3    ,	191,  	161,  	57
	DB	VK_OEM_8    ,	-1,   	-1,   	13
	DB	VK_OEM_PLUS ,	'=',  	'+',  	51
	DB	VK_OEM_COMMA,	0e1h,  	0c1h,  	12
	DB	VK_OEM_MINUS,	'-',  	'_',  	52
	DB	VK_OEM_PERIOD,	0feh,  	0deh,  	57
	DB	VK_OEM_102,	'/',   	'?',   	0	; -1
	DB	-1, '/', '?', -1
CyrTableEnd	equ	$-CyrTable
CyrCapitalTable label	byte

	DB	VK_DECIMAL,	0deh		; î
	DB	VK_OEM_1    ,	0c6h		; ¦
	DB	VK_OEM_7    ,	0ddh		; í
	DB	VK_OEM_4    ,	0d5h		; å
	DB	VK_OEM_6    ,	0dah		; ê
	DB	VK_OEM_COMMA,	0c1h  		; ¡
	DB	VK_OEM_PERIOD,	0deh		; î

CyrCapitalTableEnd	label byte

		sEnd	DATA

		sBegin	CODE
		assumes	cs, CODE
		assumes	ds, DATA
 ;
		cProc	CyrLoad, <PUBLIC>
		ParmW	d
		ParmW	i
		cBegin
		mov	bx, offset CyrTable
		add	bx, i
		mov	al, byte ptr d
		mov	[bx], al
		cEnd
;
;		cProc	CyrTrs, <PUBLIC>
;		parmW	vk_key
;		parmW	shift
;		parmW	caps
;		cBegin
;		mov	bx, vk_key
;		mov	si, offset CyrTable
;find_vk	:       mov	al, [si]
;		cmp	al, -1
;		je	find_ok
;		cmp	al, bl
;		je	find_ok
;		add	si, 4
;		jmp	short find_vk
;find_ok	:	cmp	shift, 0		; is shift key pressed ?
;		je	nosh
;     		cmp	caps, 0			; is caps key toggled ?
;		je	shifts
;		jmp	short capssh
;nosh	:	cmp	caps, 0
;		je	normal
;		jmp	capss
;normal	:	jmp	short CyrTrsDone
;shifts	:	inc	si
;		jmp	short CyrTrsDone
;capssh	:	cmp	bl, VK_0
;		jl	noact
;		cmp	bl, VK_9
;		jg	noact
;		inc	si
;		jmp	short CyrTrsDone
;noact	:       jmp	short CyrTrsDone
;capss	:	cmp	bl, VK_0
;		jl	noactc
;		cmp	bl, VK_9
;		jg	noactc
;		jmp	short CyrTrsDone
;noactc	:	inc	si
;CyrTrsDone:	inc	si
;		mov	al, byte ptr [si]
;		xor	ah, ah
;		cEnd
		;
		;	New TRS function:
		;
		cProc	CyrNewTrs, <PUBLIC>
		parmW	vk_key
		parmW	shift
		parmW	caps
		cBegin
		mov	bl, BYTE PTR vk_key
		mov	si, offset CyrTable
		inc	si
		inc	si
		inc	si
find_vk	:       mov	al, BYTE PTR [si]
                cmp     al, 0
		je	find_ok
		cmp	al, bl
		je	find_ok
		add	si, 4
		jmp	short find_vk
find_ok	:	dec	si
		dec	si
		dec	si
		cmp	shift, 0		; is shift key pressed ?
		je	nosh
     		cmp	caps, 0			; is caps key toggled ?
		je	shifts
		jmp	short capssh
nosh	:	cmp	caps, 0
		je	normal
		jmp	capss
normal	:	jmp	short CyrTrsDone
shifts	:	inc	si
                jmp     short CyrTrsDone        ;  DMY - Mufel !
capssh  :       cmp     bl, 2                   ;  Scan code of '1'
                jl      noact                   ;
                cmp     bl, 11                  ;  Scan code of '0'
		jg	noact
		inc	si
		jmp	short CyrTrsDone
noact   :       jmp     short CyrTrsDone        ;  DMY - Mufel !   
capss   :       cmp     bl, 2                   ;  Scan code of '1'
                jl      noactc                  ;                  
                cmp     bl, 11                  ;  Scan code of '0'
                jg      noactc                                     
		jmp	short CyrTrsDone
noactc	:	inc	si
CyrTrsDone:	inc	si
		mov	al, byte ptr [si]
		xor	ah, ah
		cEnd
		sEnd	CODE
		end
