Listing 1

------------------------------------------------------------
puttext_write(x,y,xsize,ysize,string,attr,buffer)
int x,y,xsize,ysize;
char *string, attr, *buffer;
{
char *maxbuffer;

if (x >= xsize || y >= ysize)           /* Range Errors  */
   return;

maxbuffer = buffer+(xsize*ysize*2)-1;
/* maxbuffer points to the attribute of the last character */

buffer += (((y*xsize)+x)*2);
/* buffer points to the first character to write */
                                             
/* While buffer is not overrun and there are characters left
 * to print.
 */
while ((buffer < maxbuffer) && (*string != '\0')) {
   *buffer++ = *string++;               /* Do character  */
   *buffer++ = attr;                    /* Do attribute  */
   }
}
------------------------------------------------------------


