I am looking for a C source code for something
that will put sinewaves on my dos computer
when it boot's up.
I just like the idea of having an osciliscope
or several sine waves, run across the screen
after dos boots up, I think It looks cool.
So far I have been able to find the following
program, from a C Text Book, But I can't
get any more Sine Waves than 2 on the screen.
Does anyone know where I can find C source code
to put something like an osciliscope or several
sine waves on the screen. That is what I am looking
for.
Thank You
Dale
/*
Sine.c
plots sine function, demonstrates putpixel()
wrinten for Turbo C++
Taken From
The Waite Group's
C Programming Using Turbo C++
Second Edition
page 372
In the book it is called plot.c,
*/
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <time.h>
#include <string.h>
void main(void)
{
int driver, mode; /* graphics driver and mode */
double angle, sinofA, cosofA; /* angle and sin of angle */
int t, u, v, w, x, y, z; /* screen coordinates */
w = 0;
t = 0;
registerbgidriver(EGAVGA_driver);
driver = DETECT; /* auto detect
initialize graphics */
initgraph(&driver, &mode, "" );
/* initgraph(&driver, &mode, "c:\\tc2\\bgi"); */
/* line( 0, 100, 200, 100); */
for( z = 0 ; z < 1000 ; z++){
v = 600;
t = t + 1;
if( t <= 100)
w++;
if( t > 100)
w--;
if( t >= 200 )
t = 0;
for( x=0 ; x < v ; x++ )
{
angle = ( (double)x / 200 * ( 2 * 3.14159265) );
sinofA = sin(angle);
cosofA = cos(angle);
y = 250 - w * sinofA ;
putpixel(x, y, LIGHTGREEN);
y = 250 - w * cosofA ;
putpixel(x, y, LIGHTBLUE);
};
for( u=0 ; u < 10000 ; u++);
for( x=0 ; x < v ; x++ )
{
angle = ( (double)x / 200 * ( 2 * 3.14159265) );
sinofA = sin(angle);
cosofA = cos(angle);
y = 250 - w * sinofA ;
putpixel(x, y, BLACK);
y = 250 - w * cosofA ;
putpixel(x, y, BLACK);
};
}; /* end of 1st For Statement */
closegraph();
}
/*
angle 0.0, 1.6, 3.1, 4.7, 6.2
sin 0.0 1.0 0.0 -1.0 0.0
x 0 50 100 150 199
y 100 200 100 0 96
*/