#include <tom.h>

#define COLS   80
#define ROWS   25
typedef unsigned  ( far *VIDEO) [COLS];
typedef unsigned  ( far *VSTREAM);
#define VSEG   ((VIDEO) (0xb800L shl 16) )
#define VSTSEG ((VSTREAM) (0xb800L shl 16) )
#define attr   0x0300
#define stat   0x3da

void vputc();
void vputstream();

char string1[80] = "This is a test";
VIDEO scrptr;
VSTREAM vsptr;

main()
begin
   char *strptr;
   VSTREAM vptr;
   int  row, col;
   int  color;
   int   i;

   row = 10;
   col = 20;
   color = attr;
   scrptr = VSEG;
   vsptr = VSTSEG;

   strptr = string1;
   vptr   = vsptr;
   for ( i = 0 ; i< 2000; i++)
      vputstream(vptr++, 'A', 0x0c00);
end

void vputc(row, col, c, color)
int   row, col;
byte  c;
int   color;
begin
   while ((inp(stat) bitand 1) not 0)
      ;
   while ((inp(stat) bitand 1) equals 0)
      ;
   scrptr [row] [col] = (color bitor c);
end

void vputstream(ptr, c, color)
VSTREAM ptr;
byte  c;
int   color;
begin
   while ((inp(stat) bitand 1) not 0)
      ;
   while ((inp(stat) bitand 1) equals 0)
      ;
   *ptr = (color bitor c);
end
