	name	ati4

	.386p

INCLUDE	..\common\vgadrvr.inc

_CODE	SEGMENT DWORD PUBLIC 'CODE'

ASSUME	cs:_CODE

	org	0

smo	EQU	offset set_mode
mspo	EQU	offset set_page
cco	EQU	offset CCOPY

head	vga_header	<,,6ah,55h,,62h,63h,64h,,smo,sml,mspo,mspl,mspo,mspl,cco,ccl>

NUMPAGES	equ	2

setpage	MACRO	srcpage,dstpage	; page to be set is in ah
	IFIDNI	<dstpage>,<ah>	; dst == ah
	IFIDNI	<srcpage>,<ah>	; dst == ah && src == ah
	mov	al,ah
	shl	ah,4
	or	ah,al
	ELSE			; dst == ah && src != ah
	mov	al,srcpage
	shl	al,4
	or	ah,al
	ENDIF
	ELSE			; dst != ah
	IFIDNI	<srcpage>,<ah>	; dst != ah && src == ah
	IFDIFI	<dstpage>,<al>	; dst != ah && src == ah && dst != al
	mov	al,dstpage
	ENDIF
	shl	ah,4
	or	ah,al
	ELSE			; dst != ah && src != ah
	mov	ah,srcpage
	shl	ah,4
	or	ah,dstpage
	ENDIF
	ENDIF

	shl	ah,1
	mov	al,0b2h		; register 0b2h
	push	edx
	mov	dx,1ceh
	out	dx,ax		; set the page
	pop	edx
		ENDM

set_mode	PROC NEAR
	push	edx
	xor	ah,ah		; function 0 = set mode
;	mov	bl,al		; save mode
	int	10h
	; read the mode back from BIOS to make sure we actually changed
	; it
;	mov	ah,0fh
;	int	10h		; get current mode
;	cmp	al,bl
;	jnz	local_bad
;	mov	ax,0c000h	; point to the VGA ROM
;	mov	es,ax
;	mov	bx,10h		; get the extended i/o address
;	mov	dx,es:[bx]
;	mov	cs:[ioaddr],dx
	mov	dx,01ceh
	mov	al,0beh		; point to misc register
	cli
	out	dx,al
	inc	edx
	in	al,dx
	or	al,8		; enable two page pointers
	out	dx,al
	sti
	xor	eax,eax		; return OK
	pop	edx
	ret
;local_bad:
;	mov	ax,08002h	; non-supported mode
;	ret
sml	EQU	$ - offset set_mode
set_mode	ENDP

include	ccopy2.asm

copyright db	10, 13, 'ATI Version 4/5 driver '
include version.asm
include date.asm
	db	10, 13
	db	'Copyright (c) 1992 Starnet Communications '
	db	'Corporation. All rights reserved.',10,13,'$'

set_page	PROC NEAR
	push	edx
	mov	ah,al		; page
	shl	ah,4
	or	ah,al
	shl	ah,1
	mov	al,0b2h		; register 0b2h
	mov	dx,1ceh
	out	dx,ax		; set the page
	pop	edx
	ret
mspl	EQU	$ - offset set_page
set_page	ENDP

_CODE	ENDS
	END
