
// Write characters to buffer.
//  Oldest data is removed to
//  make room for new data when
//  the buffer is full.

int putchar (int c)
   {

   WritePI ( putcharPtr, c);

   putcharPtr +=4;

   // Wrap around if at end of output buffer
   if (putcharPtr == (PUTCHAR_BUF_START + PUTCHAR_BUF_LENGTH))
      {
      putcharPtr = PUTCHAR_BUF_START;

      // Turn wrap around flag on
      WritePI ( PUTCHAR_FLAG, -1 );
      }

   // Store putchar position address
   WritePI ( PUTCHAR_BUF_POS, putcharPtr );

   }

void EndPrintf (void)
   {

   // Terminate screen buffer
   (void) putchar ( (int)0) ;

   // Set putchar output storage address to beginning
   putcharPtr = PUTCHAR_BUF_START;

   }

