Subj : Re: A really stupid Question - how to build a library To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Wed Oct 06 2004 09:18 pm D Kat wrote: >each time an end of buffer is reached..... Then of course there are the >counters (ticks for each call to the interrupt) and other variables that are >needed by the main program. I seem to be going around in circles on this. Forget for a minute what the Main program needs..... Put everything the Library code needs, in the Library. Then, think about what the Main program needs to know. Anything that the Main doesn't need to know, make static. Probably readlength[] and playndx; static int readlength[whatever]; static int playndx; Everything the Main program needs to know, declare in a Header file as extern. extern int TIMERS; extern int counter[]; extern int timer[]; > int button,i; // button iterator > unsigned char PA_buttons,PC_buttons; // temp holding register for current > for (i=0;i if (counter[0] == file_length)PLAYFLAG=0; Program defensively, check >= instead of == > if (PLAYFLAG==1) > { > if (counter[1] == (readlength[playndx]-1)) Program defensively, check >= instead of == > {//if at end of buffer point to next buffer > playndx++; > if(playndx==NUMBUF)playndx=0;//next buffer at 0 if beyond last buffer Program defensively, check >= instead of == > if(readlength[playndx]<2) PLAYFLAG=0;//if buffer empty - stop play > else{ //else setup to play next buffer and read next buffer > da_point = &wavebuffer[playndx][0]; //point to next buffer to play > counter[1]=0;//counter for this buffer set to beginning > READ = 1; > }// read flag: buffer is empty -> fill buffer > } This loops the output if the buffer is empty? > outpw(DA_0,*da_point); > outpw(DA_1,*da_point++); > } .