     1                                  ; ****************************************************************************
     2                                  ; SETMODE.ASM - Set Video Mode sample for MSDOS (For TRDOS 386 v2, Erdogan) 
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Special fd boot sector for int 10h video hacking (reverse vbios engineering)
     5                                  ; ((for TRDOS 386 v2 project, for video bios functions in protected mode))
     6                                  ; ----------------------------------------------------------------------------
     7                                  ; Beginning & Last Update: 16/11/2020
     8                                  ; ----------------------------------------------------------------------------
     9                                  ; Assembler: NASM version 2.15
    10                                  ; ----------------------------------------------------------------------------
    11                                  ; nasm setmode.s -l setmode.lst -o SETMODE.COM -Z error.txt
    12                                  ; ****************************************************************************
    13                                  
    14                                  		[BITS 16]
    15                                  		[ORG 100h]
    16                                  
    17 00000000 66BE[5A000000]          		mov	esi, message1
    18 00000006 E84300                  		call	print_msg
    19                                  
    20 00000009 30E4                    		xor	ah, ah
    21 0000000B CD16                    		int	16h
    22                                  
    23 0000000D B80100                  		mov	ax, 1 ; mode 1 
    24 00000010 CD10                    		int	10h
    25                                  
    26 00000012 66BE[8B000000]          		mov	esi, message2
    27 00000018 E83100                  		call	print_msg
    28                                  key_loop:
    29 0000001B 30E4                    		xor	ah, ah
    30 0000001D CD16                    		int	16h
    31                                  
    32 0000001F 3C0D                    		cmp	al, 13 ; ENTER key
    33 00000021 7416                    		je	short crlf
    34                                  			
    35 00000023 3C1B                    		cmp	al, 27 ; ESCape key
    36 00000025 741D                    		je	short terminate
    37                                  
    38 00000027 3C03                    		cmp	al, 3 ; CTRL+C
    39 00000029 7419                    		je	short terminate
    40                                  
    41 0000002B 83F800                  		cmp	ax, 0 ; CTRL+BREAK
    42 0000002E 7414                    		je	short terminate
    43                                  print_char:
    44 00000030 B40E                    		mov	ah, 0Eh
    45 00000032 BB0700                  		mov	bx, 07h
    46 00000035 CD10                    		int	10h
    47 00000037 EBE2                    		jmp	short key_loop 
    48                                  crlf:
    49 00000039 B40E                    		mov	ah, 0Eh  ; Carriage return
    50 0000003B BB0700                  		mov	bx, 07h
    51 0000003E CD10                    		int	10h
    52 00000040 B00A                    		mov	al, 0Ah  ; Line feed 
    53 00000042 EBEC                    		jmp	short print_char
    54                                  terminate:
    55 00000044 B80300                  		mov	ax, 3 ; mode 3
    56 00000047 CD10                    		int	10h		
    57                                  
    58 00000049 CD20                    		int	20h
    59                                  _retn:
    60 0000004B C3                      		retn	
    61                                  print_msg:
    62 0000004C B40E                    		mov	ah, 0Eh
    63 0000004E BB0700                  		mov	bx, 07h
    64                                  next_char:
    65 00000051 AC                      		lodsb
    66 00000052 20C0                    		and	al, al
    67 00000054 74F5                    		jz	short _retn
    68 00000056 CD10                    		int	10h		
    69                                  
    70 00000058 EBF7                    		jmp	short next_char
    71                                  
    72                                  ;-----------------------------------------------------------------
    73                                  ;  MESSAGES
    74                                  ;-----------------------------------------------------------------
    75                                  
    76                                  message1:
    77 0000005A 0D0A                    	db	0Dh, 0Ah
    78 0000005C 50726573732061206B-     	db	"Press a key to set video mode 1 (40x25 text)"
    78 00000065 657920746F20736574-
    78 0000006E 20766964656F206D6F-
    78 00000077 646520312028343078-
    78 00000080 3235207465787429   
    79 00000088 0D0A00                  	db	0Dh, 0Ah, 0
    80                                  message2:
    81 0000008B 0D0A0D0A                	db	0Dh, 0Ah, 0Dh, 0Ah
    82 0000008F 507265737320455343-     	db	"Press ESC to exit"
    82 00000098 20746F2065786974   
    83 000000A0 0D0A00                  	db	0Dh, 0Ah, 0
