Subj : Re: A really stupid Question - how to build a library To : borland.public.cpp.borlandcpp From : D Kat Date : Tue Oct 12 2004 06:42 pm "Bob Gonder" wrote in message news:6ob9m05r1ijn1ed5ojlu3uvov85ttf8qvm@4ax.com... >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[]; When I attempt to do it this way the compiler error is that the size of the type is unknown or zero..... >> int button,i; // button iterator >> unsigned char PA_buttons,PC_buttons; // temp holding register for current > >> for (i=0;i > Are there more than 2 timers? > Is TIMERS a fixed value? > If so, then unroll the loop for much better speed (important for ISRs) > >> 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++); >> } > .