home *** CD-ROM | disk | FTP | other *** search
/ Audio 4.94 - Over 11,000 Files / audio-11000.iso / msdos / sndbords / proaudio / funsrc / stat.c < prev    next >
C/C++ Source or Header  |  1993-04-05  |  3KB  |  157 lines

  1. #include <stdio.h>
  2.  
  3. char *syntax= "Syntax: stat [-bXXX]\n";
  4. char *pcmcom= "Requires that \"pcm.com\" or \"pcmfun.com\" be loaded.\n";
  5. char *pcmnot= "error: no pcm driver is loaded.\n";
  6. char *copyright= "stat - v(1.0) - Copyright Media Vision, Inc. 1992\n";
  7. char *programmer= "Bart Crane";
  8.  
  9. main(int argc, char **argv)
  10. {
  11.     unsigned int boardaddress= 0;
  12.     unsigned int pcmstatus;
  13.  
  14.     #if 0
  15.     if (argc < 2)
  16.         {
  17.         fprintf(stderr, syntax);
  18.         fprintf(stderr, pcmcom);
  19.         return(1);
  20.         }
  21.     #endif
  22.  
  23.     if (argv[1][0] == '-' && argv[1][1] == 'b')
  24.         {
  25.         char *b= &argv[1][2];
  26.  
  27.         while (isxdigit(*b))
  28.             {
  29.             boardaddress*= 16;
  30.             if (*b >= '0' && *b <= '9') boardaddress+= *b- '0';
  31.             else
  32.             if (*b >= 'A' && *b <= 'F') boardaddress+= *b- 'A'+ 10;
  33.             else
  34.             if (*b >= 'a' && *b <= 'f') boardaddress+= *b- 'a'+ 10;
  35.             b++;
  36.             }
  37.  
  38.             {
  39.             int i= 1;
  40.  
  41.             while (i < argc- 1)
  42.                 {
  43.                 argv[i]= argv[i+ 1];
  44.                 i++;
  45.                 }
  46.             argv[i]= NULL;
  47.             }
  48.  
  49.         boardaddress<<= 4;
  50.         }
  51.  
  52.     if (!checkforsig(boardaddress))
  53.         {
  54.         fprintf(stderr, pcmnot);
  55.         return(2);
  56.         }
  57.  
  58.     printf("PCM is ");
  59.  
  60.     _asm
  61.         {
  62.         push si
  63.         mov si, 0Dh
  64.         or ax, boardaddress
  65.         int 94h
  66.         pop si
  67.  
  68.         mov pcmstatus, ax
  69.         }
  70.  
  71.     if (!pcmstatus)
  72.         {
  73.         printf("waiting.");
  74.         }
  75.     else
  76.         {
  77.         if (pcmstatus& 0x8000) printf("paused ");
  78.         if (pcmstatus& 0x0001) printf("playing ");
  79.         if (pcmstatus& 0x0002) printf("recording ");
  80.  
  81.         if (pcmstatus& 0x4000) printf("SBpaused ");
  82.         if (pcmstatus& 0x0004) printf("SBPlaying ");
  83.         if (pcmstatus& 0x0008) printf("SBrecording ");
  84.  
  85.         if (boardaddress) printf("at port %X", boardaddress>> 4);
  86.         }
  87.  
  88.     putchar('\n');
  89.  
  90.     return(pcmstatus& 0x000F);
  91. }
  92.  
  93. checkforsig(int boardaddress)
  94. {
  95.     int status;
  96.     int int94isthere= 0;
  97.  
  98.     _asm
  99.         {
  100.         mov al, 94h
  101.         mov ah, 35h                    ; GETDOSVECTOR
  102.         int 21h
  103.  
  104.         mov ax, es
  105.         or ax, bx
  106.         mov int94isthere, ax
  107.  
  108.         mov bx, 107h                ; offset f_sig in segment holding int 94h
  109.  
  110.         mov ax, es:[bx][0]
  111.         xor ax, 4350h                ; 'CP'
  112.         jnz nodriver
  113.  
  114.         mov ax, es:[bx][2]
  115.         xor ax, 2D4dh                ; '-M'
  116.         jnz nodriver
  117.  
  118.         mov ax, es:[bx][4]
  119.         xor ax, 4853h                ; 'HS'
  120.         jnz nodriver
  121.  
  122.         mov ax, es:[bx][6]
  123.         xor ax, 5241h                ; 'RA'
  124.         jnz nodriver
  125.  
  126.         mov ax, es:[bx][8]
  127.         xor al, 4Bh                    ; 'K'
  128.         jnz nodriver
  129.  
  130.         cbw                            ; ax= 0
  131.  
  132.         cmp boardaddress, 0        ; board specified?
  133.         jz nodriver                
  134.  
  135.         cmp int94isthere, 0        ; 
  136.         jz nodriver
  137.         
  138.         push si
  139.         mov si, 8002h
  140.         or si, boardaddress
  141.         int 94h
  142.         pop si
  143.         or ax, ax                    ; ax= 0 if not at address, !0 if is
  144.         mov ax, 0                    ; ax= 0
  145.         jnz nodriver                ; ax= 0 if driver
  146.         dec ax                        ; ax= !0 if nodriver
  147.  
  148.         nodriver:                    
  149.  
  150.         mov status, ax                ; ax= !0 if nodriver, 0 if driver
  151.         }
  152.  
  153.     return(!status);                // status= 0 if nodriver, !0 if driver
  154. }
  155.  
  156.  
  157.