#ifndef MAIN_H /*prevent duplicated includes*/ #define MAIN_H #include "projectglobals.h" const char DEL=8; const char CLEARSCREEN[]={"\f"}; const char LINEFEED[]={"\n"}; const char CARRIAGERETURN[]={"\r"}; const char COLUMN[]={"[60C"}; const char BALL=233; const char PADDLE1=177; const char PADDLE2=178; const char BEL=7; const signed int TOPLIMIT=1; const signed int BOTTOMLIMIT=24;//24 const signed int LEFTLIMIT=1; const signed int RIGHTLIMIT=79;//79 const signed int PADDLEWIDTH=5; const signed int MAXmV=4896; const signed int PADDLESCALE=MAXmV/(BOTTOMLIMIT-TOPLIMIT-PADDLEWIDTH+1); const signed int INCREASEX=1; const signed int INCREASEY=10; const signed int WAIT_COUNT_DEC=5000; const signed int WAIT_COUNT_MIN=10000; const signed int XSCALELIMITRIGHT=30; const signed int YSCALELIMITBOTTOM=30; const signed int XSCALELIMITLEFT=-30; const signed int YSCALELIMITTOP=-30; const signed int VELOCITYSCALE=10; signed int PADDLE1Y=BOTTOMLIMIT; //holds the height of bottom of paddle 1 signed int PADDLE2Y=BOTTOMLIMIT; //holds the height of bottom of paddle 2 signed int BALLPOSITIONY=(BOTTOMLIMIT-TOPLIMIT)/2;//holds X postition of ball signed int BALLPOSITIONX=(RIGHTLIMIT-LEFTLIMIT)/2;//holds holds channel being looked at signed int BALLPOSITIONYOLD=(BOTTOMLIMIT-TOPLIMIT)/2;//holds X postition of ball signed int BALLPOSITIONXOLD=(RIGHTLIMIT-LEFTLIMIT)/2;//holds holds channel being looked at signed long COUNT=1; //holds number of cycles waited unsigned long WAIT_COUNT=30000; //number of cycles to wait before updating unsigned int i=0; unsigned int j=0; unsigned int k=0; unsigned int l=0; signed int XVELOCITYSCALE=10; signed int YVELOCITYSCALE=10; signed int XVELOCITY=1; //holds ball velocity in X direction signed int YVELOCITY=1; //holds ball velocity in Y direction void printball(){ (void) printf("%c[%i;%iH",ESC,BALLPOSITIONY,BALLPOSITIONX); //returns cursor to home BALLPOSITIONXOLD=BALLPOSITIONX; BALLPOSITIONYOLD=BALLPOSITIONY; (void) printf("%c",BALL); } extern atd; extern int voltA; extern int voltB; void paddle(){ _asm{ JSR atd } PADDLE1Y=(voltA/PADDLESCALE)+TOPLIMIT; PADDLE2Y=(voltB/PADDLESCALE)+TOPLIMIT; for(i=0;i<5;i++){ (void) printf("%c[%i;%iH",ESC,PADDLE1Y+i,LEFTLIMIT); //returns cursor to home (void) printf("%c",PADDLE1); } for(j=0;j<5;j++){ (void) printf("%c[%i;%iH",ESC,PADDLE2Y+j,RIGHTLIMIT); //returns cursor to home (void) printf("%c",PADDLE2); } } void display(){ //codes runs the display (void) printf("\f"); (void) printball(); (void) paddle(); } void ballpositionUpdate(){ if(COUNT>=WAIT_COUNT){ if(YVELOCITYSCALE>YSCALELIMITBOTTOM){ YVELOCITYSCALE=YSCALELIMITBOTTOM; } if(YVELOCITYSCALEXSCALELIMITRIGHT){ XVELOCITYSCALE=XSCALELIMITRIGHT; } if(XVELOCITYSCALE=BOTTOMLIMIT){ if(BALLPOSITIONYBOTTOMLIMIT){ BALLPOSITIONY=BOTTOMLIMIT; } YVELOCITY=(-1)*YVELOCITY; (void) printf("%c",BEL); } if(BALLPOSITIONX>=RIGHTLIMIT-1||BALLPOSITIONX<=LEFTLIMIT+1){ if(WAIT_COUNT<=WAIT_COUNT_MIN){ WAIT_COUNT=WAIT_COUNT_MIN; } else { WAIT_COUNT-=WAIT_COUNT_DEC; } if(BALLPOSITIONX>RIGHTLIMIT-1){ BALLPOSITIONX=RIGHTLIMIT-1; } if(BALLPOSITIONX