;CHAMODE -- Program to change screen modes
key_in	equ	1h	;keyboard input
pstring	equ	9h	;print string
doscall	equ	21h	;DOS interrupt num.
;**************************************************
;Segment to contain equipment flag
rom_da segment at 40h
	org 10h
eq_flag dw ?
rom_da ends
;**************************************************
codeseg segment
	assume cs:codeseg
	assume ds:codeseg
	org 100h
start:
;print intro message
	mov	dx,offset mess	;addr of mess
	mov	ah,pstring	;print string
	int	doscall		;call DOS
;set data segment to equipment flag
	assume ds:rom_da
	mov	ax,rom_da	;set DS to
	mov	ds,ax		;equipment flag
;get input letter
	mov	ah,key_in	;kbd input
	int	doscall		;call DOS
	cmp	al,'m'		;is it "m"?
	je	mono		;monochrome
	cmp	al,'h'		;is it "h"?
	je	hi_res		;hi res b and w
	cmp	al,'c'		;is it "c"?
	je	color		;320*200 color
	jmp	start		;unknown input
;set up for monochrome display
mono:
	mov	ax,eq_flag	;get equipment flag
	and	ax,11001111b	;mask off video bits
	or	ax,00110000b	;monochrome bits
	mov	eq_flag,ax	;back into flag
	mov	al,2		;80 column B & W
	mov	ah,0		;set mode func.
	int	10h		;call video BIOS
	jmp	exit
;set up for 640 * 200 BW
hi_res:
	mov	ax,eq_flag	;get equipment flag
	and	ax,11001111b	;mask off video bits
	or	ax,00100000b	;80 * 25 color card
	mov	eq_flag,ax	;back into flag
	mov	al,6		;640 * 200 BW
	mov	ah,0		;set mode function
	int	10h		;call video BIOS
	jmp	exit
;set up for 320 * 200 color mode
color:
	mov	ax,eq_flag	;get equipment flag
	and	ax,11001111b	;mask equipment flag
	or	ax,00100000b	;mask off video bits
	mov	eq_flag,ax	;back into flag
	mov	al,4		;320 *200 color
	mov	ah,0		;set mode function
	int	10h		;call video BIOS
	jmp	exit
exit:	ret
;sign_on message
mess	db 13,10
	db 'Type "m" for 80 * 25 monochrome'
	db 13,10
	db '     "h" for 640*200 b & w',13,10
	db '     "c" for 320*200 color',13,10
	db 'selection:$'
codeseg ends
;**************************************************
	end start
