; (C)opyright Erdogan Tan - March 2000
; TRQ.ASM (TRQ.COM)
; Loads Turkish fonts and
; changes keyboard (key map) and code page to Turkish.
; TSR (Terminate and Stay Resident) Type MS-DOS (TR-DOS) Program
; (If INT 20h would be used instead of INT 27h, program would be
; standalone...)

		PAGE    60,132

;哪哪哪哪哪 CODE_SEG_1  哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪
CODE_SEG_1	segment para public
		assume  CS:CODE_SEG_1, DS:CODE_SEG_1, SS:CODE_SEG_1, ES:CODE_SEG_1
		org	100h
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
;		ENTRY POINT
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
;		PROCEDURE proc_start
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
proc_start      proc    near
start:		; N-Ref=0
                jmp     load
var_INT16h_off: dw      0
var_INT16h_seg: dw      0
proc_start	endp
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
;              PROCEDURE proc_handler
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
proc_handler    proc    near
INT16h_handler:
                or      AH, 10h
                cmp     AH, 10h
                jz      short CS:loc_convert_char_codes
                jmp     Dword ptr CS:var_INT16h_off
loc_convert_char_codes:
                pushf
                call    Dword ptr CS:var_INT16h_off
                pushf
                push    AX
                push    ES
                push    SI
                mov     SI,40h
                mov     ES,SI
                mov     SI,17h
                mov     AL, Byte ptr ES:[SI]
                and     AL,08h                      ; BIOS DATA AREA
                                                    ; Keyboard Status
                pop     SI
                pop     ES
                pop     AX
                jz      short loc_check_INT16h_AH
                cmp     AH,78h
                jb      short pass_right_alt_numbers
                cmp     AH,82h
                ja      short pass_right_alt_numbers
                push    SI
                push    AX
                mov     AL,82h
                sub     AL,AH
                xor     AH,AH
                mov     SI, offset data_right_alt_numbers
                add     SI,AX
                pop     AX
                mov     AL, Byte ptr CS:[SI]
                pop     SI
                jmp     short return_from_INT16h
data_right_alt_numbers:
                db     "\}][{"               
                dw     0
                db     "$#"
                dw     0
                dw     0
pass_right_alt_numbers:
                cmp    AH,10h
                jnz    short pass_alt_right_q
                mov    AL,"@"
                jmp    short pass_alt_right_ctrl
pass_alt_right_q:
                cmp    AH,1Bh
                jnz    short pass_alt_right_5Dh
                mov    AL,"~"
                jmp    short pass_alt_right_ctrl
pass_alt_right_5Dh:
                cmp    AH,2Bh
                jnz    short pass_alt_right_59h
                mov    AL,60h
                jmp    short pass_alt_right_ctrl
                 
pass_alt_right_59h:
                cmp    AH,56h
                jnz    short pass_alt_right_ctrl
                mov    AL,"|"
pass_alt_right_ctrl:
                jmp    short return_from_INT16h
loc_check_INT16h_AH:
                cmp     AH,0
                jna     short return_from_INT16h
                cmp     AH,56h
                jnz     short pass_change_56h_ascii_codes
                cmp     AL,5Ch
                jnz     short pass_change_5Ch
                mov     AL,"<"
                jmp     short return_from_INT16h
pass_change_5Ch:
                cmp     AL,7Ch
                jnz     short return_from_INT16h
                mov     AL,">"
                jmp     short return_from_INT16h
pass_change_56h_ascii_codes:
                cmp     AH,35h
                ja      short return_from_INT16h
loc_change_al_by_xlat:
                push    DS
                push    CS
                pop     DS
                push    BX
  
                mov     BX, offset xlat_lookup_table
                xlat
                pop     BX
                pop     DS
return_from_INT16h:
                popf
                IRET
xlat_lookup_table:
         db 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
         db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,1Dh,1Eh,1Fh
         db 20h,21h,98h,5Eh,2Bh,25h,2Fh,69h,29h,3Dh,28h,5Fh,94h,2Ah,87h,2Eh
         db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,9Eh,9Fh,99h,2Dh,80h,3Ah
         db 27h,41h,42h,43h,44h,45h,46h,47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh
         db 50h,51h,52h,53h,54h,55h,56h,57h,58h,59h,5Ah,0A7h,2Ch,81h,26h,3Fh
         db 22h,61h,62h,63h,64h,65h,66h,67h,68h,08Dh,6Ah,6Bh,6Ch,6Dh,6Eh,6Fh
         db 70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7Ah,0A6h,3Bh,9Ah,82h,7Fh
         db 80h,81h,82h,83h,84h,85h,86h,87h,88h,89h,8Ah,8Bh,8Ch,8Dh,8Eh,8Fh
         db 90h,91h,92h,93h,94h,95h,96h,97h,98h,99h,9Ah,9Bh,9Ch,9Dh,9Eh,9Fh
         db 0A0h,0A1h,0A2h,0A3h,0A4h,0A5h,0A6h,0A7h,0A8h,0A9h,0AAh,0ABh,0ACh
         db 0ADh,0AEh,0AFh
         db 0B0h,0B1h,0B2h,0B3h,0B4h,0B5h,0B6h,0B7h,0B8h,0B9h,0BAh,0BBh,0BCh
         db 0BDh,0BEh,0BFh
         db 0C0h,0C1h,0C2h,0C3h,0C4h,0C5h,0C6h,0C7h,0C8h,0C9h,0CAh,0CBh,0CCh
         db 0CDh,0CEh,0CFh
         db 0D0h,0D1h,0D2h,0D3h,0D4h,0D5h,0D6h,0D7h,0D8h,0D9h,0DAh,0DBh,0DCh
         db 0DDh,0DEh,0DFh
         db 0E0h,0E1h,0E2h,0E3h,0E4h,0E5h,0E6h,0E7h,0E8h,0E9h,0EAh,0EBh,0ECh
         db 0EDh,0EEh,0EFh
         db 0F0h,0F1h,0F2h,0F3h,0F4h,0F5h,0F6h,0F7h,0F8h,0F9h,0FAh,0FBh,0FCh
         db 0FDh,0FEh,0FFh                                       
proc_handler    endp
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
;
;              PROCEDURE proc_load
;
;北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北
proc_load       proc    near
load:          
                xor     BX,BX
                mov     ES,BX
                mov     BP,58h
                mov     AX, offset INT16h_handler
                mov     DX, Word ptr ES:[BP]
                cmp     AX,DX
                jnz     short pass_INT16h_segment_ctrl
                mov     BX,DS
                cmp     Word ptr ES:[BP]+2,BX
                jz      short loc_return
pass_INT16h_segment_ctrl:
                mov     word ptr ES:[BP],AX
                mov     Word Ptr [var_INT16h_off],DX 
                mov     DX, Word ptr ES:[BP]+2
                mov     Word Ptr [var_INT16h_seg],DX
                mov     DX,DS
                mov     word ptr ES:[BP]+2,DX
                push    DS
                pop     ES
                mov	AX,1100h
		mov	BX,1000h		
		mov	CX,1			
		mov	DX,8Dh			
                mov     BP,offset var1_193          
		int	10h			; BIOS Service func ( ah ) = 11h
						; Screen function
		mov	DX,98h			
                mov     BP,offset var1_183          
		int	10h			; BIOS Service func ( ah ) = 11h
						; Screen function
		mov	CX,2			
		mov	DX,0A6h			
                mov     BP,offset var1_163          
		int	10h			; BIOS Service func ( ah ) = 11h
						; Screen function
		mov	DX,9Eh			
                mov     BP,offset var1_1A3          
		int	10h			; BIOS Service func ( ah ) = 11h
						; Screen function
                mov     SI,offset var1_1eb
loc_print:
                lodsb                           ; Load byte at DS:SI to AL
		and     AL,AL            
		je      short loc_return        ; If AL = 00h then return
		mov     AH,0Eh                  
		mov     BX,07h             
		int     10h                     ; BIOS Service func ( ah ) = 0Eh
						; Write char as TTY
						;AL-char BH-page BL-color
		jmp     short loc_print           
loc_return:
                mov     DX,offset load  
		int	27h			; Terminate and stay resident
						;DX-offset of non-resident part
var1_163        dw      3C66h, 3C00h, 0C066h
		dw	0C0C0h, 0C6DEh, 3A66h
		db	6 dup (0)
		db	66h, 3Ch, 0
                db      ';fffff>'
                db      6, 66h, 3Ch, 0
var1_183        db      18h, 18h, 0
                db      3Ch
		db	7 dup (18h)
		db	3Ch
                dd      0
var1_193        db      5 dup (0)
		db	38h
		db	5 dup (18h)
                db      3Ch
                dd      0
var1_1A3        dw      0
                db      7Ch, 0C6h, 0C6h, 60h
                db      38h, 0Ch
		db	6, 0C6h, 0C6h, 7Ch, 18h, 38h
		db	7 dup (0)
		db	7Ch, 0C6h, 60h, 38h, 0Ch, 0C6h
		db	7Ch, 18h, 38h, 0, 0
var1_1eb        db      54h, 9Ah, 52h, 4Bh, 80h
                db      'E FONT Y'
		db	9Ah
                db      'KLEND'
		db	98h
                db      '...'
                db      0Ah, 0Dh, 0h
                                                             
                                                                    
proc_load       endp

CODE_SEG_1	ends
		end	start