
	include	model.h

;
;	VGAKIT Version 4.1
;
;	Copyright 1988,89,90,91 John Bridges
;	Free for use in commercial, shareware or freeware applications
;
;	POINT.ASM
;	removed point13, range checking (Eric P)
;
;
.data

	extrn	curbk:word
	extrn	maxx:word,maxy:word,xwidth:word

.code

	extrn	newbank:proc

	public	point
	public	point_hi		; hi color Tseng 4000 support

point_hi	proc	xpos:word,ypos:word,color:word
	mov	bx,[xpos]
	mov	ax,[ypos]
	mov	dx,[maxx]

; removed all range checking on x,y for speed

	mov	dx, 640			; what a stupid way to do this
	mul	dx					;640 bytes wide in most cases
	add	bx,ax
	adc	dx,0
	mov	ax, dx			; what a $#%%# stupid microprocessor
	shl	ax, 1
; don't bother with current bank check since this looks faster

	mov	dx, 03cdh
	out	dx, ax
	mov	dx,0a000h		;setup screen segment A000
	mov	es,dx
	mov	bx, ax			; damm $#%$#%$# stupid micro
	mov	ax, [color]		;get color of pixel to plot
	mov	es:[bx], ax
;	inc	dx
;	mov	es:[dx], ah
nope1:	ret
point_hi	endp


point	proc	xpos:word,ypos:word,color:word
	mov	bx,[xpos]
	mov	ax,[ypos]
	mov	dx,[maxx]
;	cmp	bx,0			; range checking not necessary since it will
;	jl	nope2				;  always be within one 64k bank
;	cmp	bx,dx
;	jge	nope2
;	cmp	ax,0
;	jl	nope2
;	cmp	ax,[maxy]
;	jge	nope2
	mul	[xwidth]			;640 bytes wide in most cases
	add	bx,ax
	adc	dx,0
	mov	ax,dx
	cmp	ax,[curbk]
	jz	nonew
	call	newbank			;switch banks if a new bank entered
nonew:	mov	ax,0a000h		;setup screen segment A000
	mov	es,ax
	mov	al,byte ptr [color]	;get color of pixel to plot
	mov	es:[bx],al
nope2:	ret
point	endp

	end

