// Если откомпилировать с
//#define WANNA_HAVE_BUG 1
// будет зависать...
// (BC 3.1)
//----------------------------
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <dmaalloc.h>
#include <alloc.h>
#include "function.h"
main()
{
printf("Hello//n");
int BufferCapacitySamples=15000;
int MaxPulseBufSize=BufferCapacitySamples/3;// 15000 bytes
int PulseBufSize=1000;
int * pnInputBuffer=(int *)dmaalloc(BufferCapacitySamples*2+100);
int SamplingRateMks=200;
printf("%p//n",pnInputBuffer);
if (pnInputBuffer==NULL) exit(0);
long int c=0;
int Kanalja=512;// channel number
while ((c<100000L)&&(!kbhit()))
{
c++;
printf("#");
DMA_ALL_DA(pnInputBuffer+MaxPulseBufSize,PulseBufSize,
&Kanalja,1,SamplingRateMks,0,pnInputBuffer,PulseBufSize,0,0);
while (!DMA_TEST())
{
long t=100L*DMA_COUNTER();
if (PulseBufSize>0)
{
t=100-t/PulseBufSize;
if (t<0) t=0;
if (t>100) t=100;
};
printf("%-7ld:%3ld% //r",c,t);
};
DMA_OFF();
sound(8000);
STREAM_OUTDA(100);
int z=random(500);
#define WANNA_HAVE_BUG 0
#if WANNA_HAVE_BUG
printf ("Oops...");
DMAONE(pnInputBuffer,BufferCapacitySamples/10,512,
SamplingRateMks,1);
printf (" ... passed!//r");
delay(z);
DMA_OFF();
#else
DMAALL(pnInputBuffer,BufferCapacitySamples/10,&Kanalja,1,
SamplingRateMks,1);
delay(z);
DMA_OFF();
#endif
if (heapcheck()!=_HEAPOK) {printf("//nHeap corrupted!//n");exit(0);}
nosound();
};
printf("//nGood-bye//n");
return 0;
};