home *** CD-ROM | disk | FTP | other *** search
- name vmode
- page 55,132
- title 'VMODE --- Set PC Video Mode'
-
- ;
- ; VMODE utility to set display mode on IBM Personal Computer
- ;
- ; Copyright (C) 1983 Ray Duncan
- ;
- ; To assemble, link, and convert this program into
- ; a COM file, follow these steps:
- ;
- ; C>MASM VMODE;
- ; C>LINK VMODE;
- ; C>EXE2BIN VMODE.EXE VMODE.COM
- ; C>DEL VMODE.EXE
- ;
- ; Ignore the message "Warning: no stack segment" from the Linker.
- ;
-
- input equ 080h ;address of command tail
- ;buffer (set up by DOS)
- blank equ 20h ;ASCII blank code
- cr equ 0dh ;ASCII carriage return
- lf equ 0ah ;ASCII line feed
-
- cseg segment byte
-
- assume cs:cseg,ds:cseg,es:cseg,ss:cseg
-
- org 100h
-
- vmode: ;initialize DI to the
- ;address of the input buffer
- mov di,offset input
- mov al,[di] ;check if any command tail
- or al,al ;and exit if not
- jz vmode7
- mov al,blank ;load ASCII blank for scan
- inc di ;increment address in DI
- ;past the input count byte
- mov cx,80 ;scan max of 80 chars.
- cld ;clear direction flag
- repz scasb ;look for first none-blank
- ;character in input buffer
- jz vmode7 ;jump if none found
- ;load the none-blank char.,
- ;use offset of -1 since DI
- ;will be pointing past it
- mov al,-1 [di]
- cmp al,cr ;if first none-blank char
- ;was RETURN,mode was missing
- jz vmode7 ;so go print error message
- cmp al,'0' ;make sure it is range 0-7
- jb vmode8 ;exit if ASCII code < '0'
- cmp al,'7'
- ja vmode8 ;exit if ASCII code > '7'
- mov vmodeb,al ;store mode number into
- ;output string
- and al,0fh ;mask off upper four bits
- ;of char. to get 0-7
- push ax ;save mode for later
- xor bx,bx ;set ES=zero
- mov es,bx
- mov bx,410h ;set BX=addr of DOS's
- ;equipment flags word
- cmp al,7 ;check if monochrome
- ;or graphics board
- mov al,30h ;assume monochome
- jz vmode6
- mov al,20h ;no,was graphics board
-
- vmode6: ;mask off the old
- ;display equipment flags
- and byte ptr es:[bx],0cfh
- ;merge in the proper flag
- ;for newly selected display
- or es:[bx],al
- pop ax ;recover mode
- xor ah,ah ;force AH=zero
- int 10h ;and call ROM BIOS to set mode
- ;go print success message and exit
- mov dx,offset vmodea
- jmp vmode9
-
- vmode7: ;print "missing mode number"
- mov dx,offset vmodec
- jmp vmode9
-
- vmode8: ;print "illegal mode number"
- mov dx,offset vmoded
-
- vmode9: ;print the message whose
- ;address is in reg. DX
- mov ah,9 ;function 9 = print string
- int 21h ;call DOS to print
-
- mov ax,4c00h ;exit with retcode=0
- int 21h
-
- vmodea db cr,lf
- db 'Video mode set to '
- vmodeb db ' ',cr,lf,'$'
-
- vmodec db cr,lf
- db 'Missing mode number.'
- db cr,lf,'$'
-
- vmoded db cr,lf
- db 'Illegal mode number.'
- db cr,lf,'$'
-
- cseg ends
-
- end vmode