/*
	vputch.C

	Copyright (C) 1993, Geoff Friesen B.Sc.
	All rights reserved.
*/

#define	INCL_VPUTCH

#ifndef	INCL_ATTRIB
#include "attrib.C"
#endif

#ifndef INCL_UCURSOR
#include "ucursor.C"
#endif

int v_putch (int c, int count)
{
   asm cmp WORD PTR count, 0
   asm jz v_putch4

   asm mov dx, 0b000h

   asm mov bx, 0
   asm mov es, bx
   asm mov di, bx

   asm mov bl, es:[462h]

   asm cmp BYTE PTR es:[449h], MONO
   asm jz v_putch1

   asm add dh, 8
   asm add dh, bl

v_putch1:

   asm shl bx, 1

   asm mov cl, es:[bx+451h]
   asm or cl, cl
   asm jz v_putch3

   asm mov ch, 0

   asm mov al, es:[44ah]
   asm mov ah, 0
   asm shl ax, 1

v_putch2:

   asm add di, ax
   asm loop v_putch2

v_putch3:

   asm mov al, es:[bx+450h]
   asm mov ah, 0
   asm shl ax, 1
   asm add di, ax

   asm mov es, dx

   asm mov al, c
   asm mov ah, BYTE PTR attribute
   asm mov cx, count

   asm cld
   asm rep stosw

   update_cursor ();

v_putch4:

   asm mov ax, c
}