/* ftocga--float to cga 640 x 200 plot
 * ftocga < infile > outfile
 *   where infile wave ranges between +- 1 and outfile is 0 to 199
 */
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define CGASCALE 99.5

main()
{
    float x;
    short y;
    setmode(fileno(stdin), O_BINARY);
    setmode(fileno(stdout), O_BINARY);

    while (fread((char *)&x, sizeof(float), 1, stdin))
    {     
          y = x * CGASCALE+CGASCALE;
          fwrite((char *)&y, sizeof(short), 1, stdout);
    }
}