
/*  DONMON is a Microsoft C compatible C source file that will monitor */
/*  a Midi link via the Midicard interface.  It must be compiled in    */
/*  medium or large model (version 3.0 or later) and linked with       */
/*  Systems Design's TST_USR2.OBJ object file.	This file may be       */
/*  obtained by assembling TST_USR2.ASM, a public domain assembly      */
/*  language source file.					       */




main()

{
unsigned int in,out,max,c;
unsigned char *ap;


printf("\n                           Don's Midi Monitor  -  v1.0\n\n");


if(u_loc_mc() == 0)
  {
  printf("\n\nMidicard not operational or SDA.CFG not found.\n");
  return;
  }

max = 59999 + 5000;
ap = 0;
while(ap == 0)
  {
  max -= 5000;
  ap = (unsigned char *) malloc(max + 1);
  }

in = out = 0;
while(in < max)
{
c = u_rcvb();
if(c == 0x100) 
  {
  if(in > out)
    printf("%2.2X  ",*(ap + (out++)));
  else
    in = out = 0;
  }
else
  {
  u_sndb(c);
  *(ap + (in++)) = c;
  }
}

printf("\n\nBuffer Full.\n");
free(ap);
u_exit();
}
