home *** CD-ROM | disk | FTP | other *** search
/ Game Developers Magazine 3 / GDM003.ZIP / WAVEFORM.C < prev    next >
C/C++ Source or Header  |  1994-02-16  |  1KB  |  65 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <mem.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7. void    SetGraphicsMode( void ) {
  8.     asm {
  9.         mov    ax,0x13
  10.     int    0x10
  11.       }
  12. }
  13.  
  14. void    SetTextMode( void ) {
  15.     asm {
  16.       mov    ax,0x03
  17.     int    0x10;
  18.     }
  19. }
  20.  
  21. void SetPoint( int X, int Y, unsigned char C ) {
  22.   if ( X < 0 || X > 319 ) return;
  23.   if ( Y < 0 || Y > 199 ) return;
  24.   *(char far*)MK_FP(0xA000,(Y*320)+X)=C;
  25. }
  26.  
  27. unsigned char GetPoint( int X, int Y ) {
  28.   return(*(char far*)MK_FP(0xA000,(Y*320)+X));
  29. }
  30.  
  31. void DrawAxes(void) {
  32.   int x;
  33.   for ( x = 0; x < 320; x++ ) SetPoint( x, 100, 2 );
  34.   for ( x = 0; x < 200; x++ ) SetPoint( 0, x, 2 );
  35. }
  36.  
  37. void main( int argc, char **argv ) {
  38.   FILE *f;
  39.   int x,y,z;
  40.  
  41.   f = fopen(argv[1], "rb");
  42.  
  43.   while ( !feof(f) ) {
  44.     SetGraphicsMode();  // quick way of clearing the graphics screen
  45.     DrawAxes();
  46.     x = 0;
  47.     while ( x < 320 && !feof(f) ) {
  48.        y=fgetc(f)-128;
  49.        if (y==0) SetPoint(x,100,15);
  50.        else if (y<0) for (z=100+y;z<=100;z++) SetPoint(x,z,15);
  51.        else for (z=y+100;z>=100;z--) SetPoint(x,z,15);
  52.        x++;
  53.        }
  54.     if ( getch() == 27 ) break;
  55.     }
  56.  
  57.   SetTextMode();
  58.   fclose(f);
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65.