//video gen and sound //D.5 is sync:1000 ohm + diode to 75 ohm resistor //D.6 is video:330 ohm + diode to 75 ohm resistor //B.3 is sound and should have a 10k resistor to gnd #pragma regalloc- //I allocate the registers myself #pragma optsize- //optimize for speed #include #include #include #include #include //cycles = 63.625 * 16 Note NTSC is 63.55 //but this line duration makes each frame exactly 1/60 sec //which is nice for keeping a realtime clock #define lineTime 1018 #define begin { #define end } #define ScreenTop 30 #define ScreenBot 230 #define paddle 58 #define countMS 62 //ticks/mSec #define readMS 125 //NOTE that v1 to v8 and i must be in registers! register char v1 @4; register char v2 @5; register char v3 @6; register char v4 @7; register char v5 @8; register char v6 @9; register char v7 @10; register char v8 @11; register int i @12; unsigned char Ain ; // paddle position and velocity int st; char swit; char padx, pady; char padvx, lineNumber; signed char ballcentx, ballcenty; char vx,vy,oldballx,oldbally,goaliex,goaliey; char goalx, goaly, goalvx,goalvy, chance,oldgoalx,oldgoaly,goalpos,oldgoalpos, radius, oldradius; //chance = rand(); if ball is hit under a conditional. char menutimer,timer1,timer2,balltimer; char state = 0b11111111; float ax, ay, hittime; //floating for now... char ballhit = 0; //boolean for ball hit char time2goal; char framecounter; // will be used if frame separation is needed. char timer3; char shotdone = 0; char init = 1; char keytime; char play; char oldbutnum, ballmove; char blocked; int score; char fc; char keynum; char keepermoved; char calculate; int axy22, az22; signed char goalie_center_x,goalie_center_y; unsigned char butnum, key, lastkey, PushState, PushFlag, read_flag, sw; int vyp, vzp, vxp; //int time,temp1, temp2, temp3; //Testing Variables long test1, test2, test3, test4, test5; long testtime; long framecount; unsigned char random; unsigned char menu1, menu2, gamemode, credits; unsigned int axy, az, axy1, az1, axy2, az2; int dy; float g; float temp1; float temp2; float temp3; #pragma regalloc+ char syncON, syncOFF; int LineCount; int time; //Macros for calculations... #define int2fix(a) (((int)(a))<<8) //Convert char to fix. a is a char #define fix2int(a) ((signed char)((a)>>8)) //Convert fix to char. a is an int #define float2fix(a) ((int)((a)*256.0)) //Convert float to fix. a is a float #define fix2float(a) ((float)(a)/256.0) //Convert fix to float. a is an int #define multfix(a,b) ((int)((((long)(a))*((long)(b)))>>8)) //multiply two fixed # #define divfix(a,b) ((int)((((long)(a))<<8)/((long)(b)))) //divide two fixed # #define sqrtfix(a) (lsqrt(((long)(a))<<8)) //square root #define NoPush 0 #define MaybePush 1 #define Push 2 #define MaybeRelease 3 #define End_Q 4 #define Done 5 #define Pushed 2 #define MaybeNoPush 3 #define maxkeys 16 #define menu1 0 #define menu2 1 #define gamemode 2 flash unsigned char keytbl_top[16] = {0x7d, 0xee, 0xed, 0xeb, 0xde, 0xdd, 0xdb, 0xbe, 0xbd, 0xbb, 0x7e, 0x7b, 0xe7, 0xd7, 0xb7, 0x77}; // 0,1, 2, 3, 4, 5, 6, 7, 8, 9, A,B, C, D,*, # unsigned char keycode, keystate, oldkey, keycount, keystr[12]; unsigned int time2; void erase_line1(void); void erase_line3(void); void erase_line4(void); void erase_line5(void); void erase_line6(void); void erase_line7(void); void erase_line9(void); //animation char x, y, s; char screen[1600], t, ts[10]; char cu1[]="CORNELL"; char cu2[]="ECE476"; char menu1a[]="SOCCERMANIA"; char menu2a[]="1PLAYGAME"; char menu2b[]="2QUIT"; char menu3[]="3Credits"; char menu3a[]="Ozan Mutluer"; char menu3b[]="Erinc Tokluoglu"; char menu3c[]="Special Thanks to"; char menu3d[]="Bruce Land"; char s1[] = "GOALLL"; char s2[] = "OUT"; char s3[] = "SAVED"; char s4[] = "S"; char tt1[5], tt2[2]; char goal; //Musical note values //C below middle C to C above middle C //zeros are rests flash char notes[] = {239,213,189,179,159,142,126, 120,106,94,90,80,71,63,60,0,0,0,0}; char note, musicT; //Point plot lookup table //One bit masks flash char pos[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; //define some character bitmaps //5x7 characters flash char bitmap[38][7]={ //0 0b01110000, 0b10001000, 0b10011000, 0b10101000, 0b11001000, 0b10001000, 0b01110000, //1 0b00100000, 0b01100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //2 0b01110000, 0b10001000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b11111000, //3 0b11111000, 0b00010000, 0b00100000, 0b00010000, 0b00001000, 0b10001000, 0b01110000, //4 0b00010000, 0b00110000, 0b01010000, 0b10010000, 0b11111000, 0b00010000, 0b00010000, //5 0b11111000, 0b10000000, 0b11110000, 0b00001000, 0b00001000, 0b10001000, 0b01110000, //6 0b01000000, 0b10000000, 0b10000000, 0b11110000, 0b10001000, 0b10001000, 0b01110000, //7 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b10000000, //8 0b01110000, 0b10001000, 0b10001000, 0b01110000, 0b10001000, 0b10001000, 0b01110000, //9 0b01110000, 0b10001000, 0b10001000, 0b01111000, 0b00001000, 0b00001000, 0b00010000, //A 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, //B 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10001000, 0b10001000, 0b11110000, //C 0b01110000, 0b10001000, 0b10000000, 0b10000000, 0b10000000, 0b10001000, 0b01110000, //D 0b11110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11110000, //E 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b11111000, //F 0b11111000, 0b10000000, 0b10000000, 0b11111000, 0b10000000, 0b10000000, 0b10000000, //G 0b01110000, 0b10001000, 0b10000000, 0b10011000, 0b10001000, 0b10001000, 0b01110000, //H 0b10001000, 0b10001000, 0b10001000, 0b11111000, 0b10001000, 0b10001000, 0b10001000, //I 0b01110000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b01110000, //J 0b00111000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b10010000, 0b01100000, //K 0b10001000, 0b10010000, 0b10100000, 0b11000000, 0b10100000, 0b10010000, 0b10001000, //L 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11111000, //M 0b10001000, 0b11011000, 0b10101000, 0b10101000, 0b10001000, 0b10001000, 0b10001000, //N 0b10001000, 0b10001000, 0b11001000, 0b10101000, 0b10011000, 0b10001000, 0b10001000, //O 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //P 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10000000, 0b10000000, 0b10000000, //Q 0b01110000, 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10010000, 0b01101000, //R 0b11110000, 0b10001000, 0b10001000, 0b11110000, 0b10100000, 0b10010000, 0b10001000, //S 0b01111000, 0b10000000, 0b10000000, 0b01110000, 0b00001000, 0b00001000, 0b11110000, //T 0b11111000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, 0b00100000, //U 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01110000, //V 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, //W 0b10001000, 0b10001000, 0b10001000, 0b10101000, 0b10101000, 0b10101000, 0b01010000, //X 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b01010000, 0b10001000, 0b10001000, //Y 0b10001000, 0b10001000, 0b10001000, 0b01010000, 0b00100000, 0b00100000, 0b00100000, //Z 0b11111000, 0b00001000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b11111000, //figure1 0b01110000, 0b00100000, 0b01110000, 0b10101000, 0b00100000, 0b01010000, 0b10001000, //figure2 0b01110000, 0b10101000, 0b01110000, 0b00100000, 0b00100000, 0b01010000, 0b10001000}; //================================ //3x5 font numbers, then letters //packed two per definition for fast //copy to the screen at x-position divisible by 4 flash char smallbitmap[39][5]={ //0 0b11101110, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //1 0b01000100, 0b11001100, 0b01000100, 0b01000100, 0b11101110, //2 0b11101110, 0b00100010, 0b11101110, 0b10001000, 0b11101110, //3 0b11101110, 0b00100010, 0b11101110, 0b00100010, 0b11101110, //4 0b10101010, 0b10101010, 0b11101110, 0b00100010, 0b00100010, //5 0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //6 0b11001100, 0b10001000, 0b11101110, 0b10101010, 0b11101110, //7 0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b10001000, //8 0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b11101110, //9 0b11101110, 0b10101010, 0b11101110, 0b00100010, 0b01100110, //: 0b00000000, 0b01000100, 0b00000000, 0b01000100, 0b00000000, //= 0b00000000, 0b11101110, 0b00000000, 0b11101110, 0b00000000, //blank f 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, //A 0b11101110, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //B 0b11001100, 0b10101010, 0b11101110, 0b10101010, 0b11001100, //C 0b11101110, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //D 0b11001100, 0b10101010, 0b10101010, 0b10101010, 0b11001100, //E 0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b11101110, //F 0b11101110, 0b10001000, 0b11101110, 0b10001000, 0b10001000, //G 0b11101110, 0b10001000, 0b10001000, 0b10101010, 0b11101110, //H 0b10101010, 0b10101010, 0b11101110, 0b10101010, 0b10101010, //I 0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b11101110, //J 0b00100010, 0b00100010, 0b00100010, 0b10101010, 0b11101110, //K 0b10001000, 0b10101010, 0b11001100, 0b11001100, 0b10101010, //L 0b10001000, 0b10001000, 0b10001000, 0b10001000, 0b11101110, //M 0b10101010, 0b11101110, 0b11101110, 0b10101010, 0b10101010, //N 0b00000000, 0b11001100, 0b10101010, 0b10101010, 0b10101010, //O 0b01000100, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //P 0b11101110, 0b10101010, 0b11101110, 0b10001000, 0b10001000, //Q 0b01000100, 0b10101010, 0b10101010, 0b11101110, 0b01100110, //R 0b11101110, 0b10101010, 0b11001100, 0b11101110, 0b10101010, //S 0b11101110, 0b10001000, 0b11101110, 0b00100010, 0b11101110, //T 0b11101110, 0b01000100, 0b01000100, 0b01000100, 0b01000100, //U 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b11101110, //V 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b01000100, //W 0b10101010, 0b10101010, 0b11101110, 0b11101110, 0b10101010, //X 0b00000000, 0b10101010, 0b01000100, 0b01000100, 0b10101010, //Y 0b10101010, 0b10101010, 0b01000100, 0b01000100, 0b01000100, //Z 0b11101110, 0b00100010, 0b01000100, 0b10001000, 0b11101110 }; //================================== //This is the sync generator and raster generator. It MUST be entered from //sleep mode to get accurate timing of the sync pulses #pragma warn- interrupt [TIM1_COMPA] void t1_cmpA(void) begin //Increment the menu timer... timer1++; timer2++; timer3--; time2--; //start the Horizontal sync pulse PORTD = syncON; //update the curent scanline number LineCount ++ ; //begin inverted (Vertical) synch after line 247 if (LineCount==248) begin syncON = 0b00100000; //32 syncOFF = 0; end //back to regular sync after line 250 if (LineCount==251) begin syncON = 0; syncOFF = 0b00100000; //32 end //start new frame after line 262 if (LineCount==263) begin st++; LineCount = 1; keytime++; testtime++; menutimer++; balltimer++; // if ball is shot. end delay_us(2); //adjust to make 5 us pulses //end sync pulse PORTD = syncOFF; if (LineCount=ScreenTop) begin //compute byte index for beginning of the next line //left-shift 4 would be individual lines // <<3 means line-double the pixels //The 0xfff8 truncates the odd line bit //i=(LineCount-ScreenTop)<<3 & 0xfff8; // #asm push r16 lds r12, _LineCount lds r13, _Linecount+1 ldi r16, 30 sub r12, r16 ldi r16,0 sbc r13, r16 lsl r12 rol r13 lsl r12 rol r13 lsl r12 rol r13 mov r16,r12 andi r16,0xf0 mov r12,r16 pop r16 #endasm //load 16 registers with screen info #asm push r14 push r15 push r16 push r17 push r18 push r19 push r26 push r27 ldi r26,low(_screen) ;base address of screen ldi r27,high(_screen) add r26,r12 ;offset into screen (add i) adc r27,r13 ld r4,x+ ;load 16 registers and inc pointer ld r5,x+ ld r6,x+ ld r7,x+ ld r8,x+ ld r9,x+ ld r10,x+ ld r11,x+ ld r12,x+ ld r13,x+ ld r14,x+ ld r15,x+ ld r16,x+ ld r17,x+ ld r18,x+ ld r19,x pop r27 pop r26 #endasm delay_us(4); //adjust to center image on screen //blast 16 bytes to the screen #asm ;but first a macro to make the code shorter ;the macro takes a register number as a parameter ;and dumps its bits serially to portD.6 ;the nop can be eliminated to make the display narrower .macro videobits ;regnum BST @0,7 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,6 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,5 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,4 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,3 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,2 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,1 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 BST @0,0 IN R30,0x12 BLD R30,6 nop OUT 0x12,R30 .endm videobits r4 ;video line -- byte 1 videobits r5 ;byte 2 videobits r6 ;byte 3 videobits r7 ;byte 4 videobits r8 ;byte 5 videobits r9 ;byte 6 videobits r10 ;byte 7 videobits r11 ;byte 8 videobits r12 ;byte 9 videobits r13 ;byte 10 videobits r14 ;byte 11 videobits r15 ;byte 12 videobits r16 ;byte 13 videobits r17 ;byte 14 videobits r18 ;byte 15 videobits r19 ;byte 16 clt ;clear video after the last pixel on the line IN R30,0x12 BLD R30,6 OUT 0x12,R30 pop r19 pop r18 pop r17 pop r16 pop r15 pop r14 #endasm end end #pragma warn+ //================================== //plot one point //at x,y with color 1=white 0=black 2=invert #pragma warn- void video_pt(char x, char y, char c) begin #asm ; i=(x>>3) + ((int)y<<4) ; the byte with the pixel in it push r16 ldd r30,y+2 ;get x lsr r30 lsr r30 lsr r30 ;divide x by 8 ldd r12,y+1 ;get y lsl r12 ;mult y by 16 clr r13 lsl r12 rol r13 lsl r12 rol r13 lsl r12 rol r13 add r12, r30 ;add in x/8 ;v2 = screen[i]; r5 ;v3 = pos[x & 7]; r6 ;v4 = c r7 ldi r30,low(_screen) ldi r31,high(_screen) add r30, r12 adc r31, r13 ld r5,Z ;get screen byte ldd r26,y+2 ;get x ldi r27,0 andi r26,0x07 ;form x & 7 ldi r30,low(_pos*2) ldi r31,high(_pos*2) add r30,r26 adc r31,r27 lpm r6,Z ld r16,y ;get c ;if (v4==1) screen[i] = v2 | v3 ; ;if (v4==0) screen[i] = v2 & ~v3; ;if (v4==2) screen[i] = v2 ^ v3 ; cpi r16,1 brne tst0 or r5,r6 tst0: cpi r16,0 brne tst2 com r6 and r5,r6 tst2: cpi r16,2 brne writescrn eor r5,r6 writescrn: ldi r30,low(_screen) ldi r31,high(_screen) add r30, r12 adc r31, r13 st Z, r5 ;write the byte back to the screen pop r16 #endasm end #pragma warn+ //================================== // put a big character on the screen // c is index into bitmap void video_putchar(char x, char y, char c) begin v7 = x; for (v6=0;v6<7;v6++) begin v1 = bitmap[c][v6]; v8 = y+v6; video_pt(v7, v8, (v1 & 0x80)==0x80); video_pt(v7+1, v8, (v1 & 0x40)==0x40); video_pt(v7+2, v8, (v1 & 0x20)==0x20); video_pt(v7+3, v8, (v1 & 0x10)==0x10); video_pt(v7+4, v8, (v1 & 0x08)==0x08); end end //================================== // put a string of big characters on the screen void video_puts(char x, char y, char *str) begin char i ; for (i=0; str[i]!=0; i++) begin if (str[i]>=0x30 && str[i]<=0x3a) video_putchar(x,y,str[i]-0x30); else video_putchar(x,y,str[i]-0x40+9); x = x+6; end end //================================== void video_clear(void) begin int i; for (i=0;i<1600;i++) screen[i]=0; end //*********************************** // put a small character on the screen // x-cood must be on divisible by 4 // c is index into bitmap void video_smallchar(char x, char y, char c) begin char mask; i=((int)x>>3) + ((int)y<<4) ; if (x == (x & 0xf8)) mask = 0x0f; //f8 else mask = 0xf0; screen[i] = (screen[i] & mask) | (smallbitmap[c][0] & ~mask); screen[i+16] = (screen[i+16] & mask) | (smallbitmap[c][1] & ~mask); screen[i+32] = (screen[i+32] & mask) | (smallbitmap[c][2] & ~mask); screen[i+48] = (screen[i+48] & mask) | (smallbitmap[c][3] & ~mask); screen[i+64] = (screen[i+64] & mask) | (smallbitmap[c][4] & ~mask); end //================================== // put a string of small characters on the screen // x-cood must be on divisible by 4 void video_putsmalls(char x, char y, char *str) begin char i ; for (i=0; str[i]!=0; i++) begin if (str[i]>=0x30 && str[i]<=0x3a) video_smallchar(x,y,str[i]-0x30); else video_smallchar(x,y,str[i]-0x40+12); x = x+4; end end //================================== //plot a line //at x1,y1 to x2,y2 with color 1=white 0=black 2=invert //NOTE: this function requires signed chars //Code is from David Rodgers, //"Procedural Elements of Computer Graphics",1985 void video_line(char x1, char y1, char x2, char y2, char c) begin int e; signed char dx,dy,j, temp; signed char s1,s2, xchange; signed char x,y; x = x1; y = y1; dx = cabs(x2-x1); dy = cabs(y2-y1); s1 = csign(x2-x1); s2 = csign(y2-y1); xchange = 0; if (dy>dx) begin temp = dx; dx = dy; dy = temp; xchange = 1; end e = ((int)dy<<1) - dx; for (j=0; j<=dx; j++) begin video_pt(x,y,c) ; if (e>=0) begin if (xchange==1) x = x + s1; else y = y + s2; e = e - ((int)dx<<1); end if (xchange==1) y = y + s2; else x = x + s1; e = e + ((int)dy<<1); end end //================================== //return the value of one point //at x,y with color nonzero=white 0=black char video_set(char x, char y) begin //The following construction //detects exactly one bit at the x,y location i=((int)x>>3) + ((int)y<<4) ; return ( screen[i] & 1<<(7-(x & 0x7))); end //================================== //Procedures //ADC for the acceleration readings in (x,y) and z void readADCs(void) begin unsigned int adc_data1,adc_data2,adc_data; adc_data2 = ADCL; adc_data1 = ADCH; //take in 8 bits to rightmost side of 16bit int adc_data = ((unsigned int)adc_data1) << 8; //shift the 8 bits of ADCH into the top 8 bits, '0's shifted into right hand side adc_data = adc_data | ((unsigned int)adc_data2); //bit-wise OR the 16 bit int with 8 bit char adc_data = adc_data >> 6; //get integer value of adc_data if((ADMUX & 0x1f) == 2) begin az1 = adc_data; //finding linear value, changes cueTip ADMUX &= 0xe0; ADMUX |= 0x03; //go to read rotation end else if((ADMUX & 0x1f) == 3) begin axy1=adc_data; ADMUX &= 0xe0; ADMUX |= 0x02; //go to read accelaration1 end ADCSRA= ADCSRA | 0x40; //allow interrupts to occur end //drawball void drawball(char x, char y,char r) { //Local variables; if(r==2){ video_pt(x-1,y-r,1); video_pt(x,y-r,1); video_pt(x+1,y-r,1); video_pt(x+r,y-1,1); video_pt(x+r,y,1); video_pt(x+r,y+1,1); video_pt(x-r,y-1,1); video_pt(x-r,y,1); video_pt(x-r,y+1,1); video_pt(x-1,y+r,1); video_pt(x,y+r,1); video_pt(x+1,y+r,1); } if(r==3){ video_pt(x-1,y-2,1); video_pt(x,y-2,1); video_pt(x+1,y-2,1); video_pt(x+2,y-2,1); video_pt(x+r,y-1,1); video_pt(x+r,y,1); video_pt(x+r,y+1,1); video_pt(x+r,y+2,1); video_pt(x-2,y-1,1); video_pt(x-2,y,1); video_pt(x-2,y+1,1); video_pt(x-2,y+2,1); video_pt(x-1,y+r,1); video_pt(x,y+r,1); video_pt(x+1,y+r,1); video_pt(x+2,y+r,1); } if(r==4){ video_pt(x-1,y-r+1,1); video_pt(x,y-r+1,1); video_pt(x+1,y-r+1,1); video_pt(x+r-1,y-1,1); video_pt(x+r-1,y,1); video_pt(x+r-1,y+1,1); video_pt(x-r+1,y-1,1); video_pt(x-r+1,y,1); video_pt(x-r+1,y+1,1); video_pt(x-1,y+r-1,1); video_pt(x,y+r-1,1); video_pt(x+1,y+r-1,1); video_pt(x+2,y+2,1); video_pt(x-2,y+2,1); video_pt(x+2,y-2,1); video_pt(x-2,y-2,1); } } //Erase old ball..call this in setTrajectory(), using old positions... void eraseOldball(char x, char y,char r) { //Local variables; if(r==2){ video_pt(x-1,y-2,0); video_pt(x,y-2,0); video_pt(x+1,y-2,0); video_pt(x+2,y-1,0); video_pt(x+2,y,0); video_pt(x+2,y+1,0); video_pt(x-2,y-1,0); video_pt(x-2,y,0); video_pt(x-2,y+1,0); video_pt(x-1,y+2,0); video_pt(x,y+2,0); video_pt(x+1,y+2,0); } if(r==3){ video_pt(x-1,y-2,0); video_pt(x,y-2,0); video_pt(x+1,y-2,0); video_pt(x+2,y-2,0); video_pt(x+r,y-1,0); video_pt(x+r,y,0); video_pt(x+r,y+1,0); video_pt(x+r,y+2,0); video_pt(x-2,y-1,0); video_pt(x-2,y,0); video_pt(x-2,y+1,0); video_pt(x-2,y+2,0); video_pt(x-1,y+r,0); video_pt(x,y+r,0); video_pt(x+1,y+r,0); video_pt(x+2,y+r,0); } if(r==4){ video_pt(x-1,y-r+1,0); video_pt(x,y-r+1,0); video_pt(x+1,y-r+1,0); video_pt(x+r-1,y-1,0); video_pt(x+r-1,y,0); video_pt(x+r-1,y+1,0); video_pt(x-r+1,y-1,0); video_pt(x-r+1,y,0); video_pt(x-r+1,y+1,0); video_pt(x-1,y+r-1,0); video_pt(x,y+r-1,0); video_pt(x+1,y+r-1,0); video_pt(x+2,y+2,0); video_pt(x-2,y+2,0); video_pt(x+2,y-2,0); video_pt(x-2,y-2,0); } } //******************************* void draw_line5(void){ video_pt(padx, pady , 1); video_pt(padx, pady -1, 1); video_pt(padx, pady -2, 1); video_pt(padx, pady -3, 1); video_pt(padx, pady -4, 1); video_pt(padx, pady -5, 1); video_pt(padx, pady -6, 1); video_pt(padx, pady -7, 1); video_pt(padx, pady -8, 1); video_pt(padx, pady -9, 1); video_pt(padx, pady -10, 1); video_pt(padx, pady -11, 1); video_pt(padx, pady -12, 1); video_pt(padx, pady -13, 1); video_pt(padx, pady -14, 1); video_pt(padx, pady -15, 1); video_pt(padx, pady -16, 1); lineNumber = 5; erase_line1(); erase_line3(); erase_line4(); erase_line6(); erase_line7(); erase_line9(); } void erase_line5(void){ video_pt(padx, pady , 0); video_pt(padx, pady -1, 0); video_pt(padx, pady -2, 0); video_pt(padx, pady -3, 0); video_pt(padx, pady -4, 0); video_pt(padx, pady -5, 0); video_pt(padx, pady -6, 0); video_pt(padx, pady -7, 0); video_pt(padx, pady -8, 0); video_pt(padx, pady -9, 0); video_pt(padx, pady -10, 0); video_pt(padx, pady -11, 0); video_pt(padx, pady -12, 0); video_pt(padx, pady -13, 0); video_pt(padx, pady -14, 0); video_pt(padx, pady -15, 0); video_pt(padx, pady -16, 0); } void draw_line7(void){ video_pt(padx, pady , 1); video_pt(padx-1, pady -1, 1); video_pt(padx-2, pady -2, 1); video_pt(padx-3, pady -3, 1); video_pt(padx-4, pady -4, 1); video_pt(padx-5, pady -5, 1); video_pt(padx-6, pady -6, 1); video_pt(padx-7, pady -7, 1); video_pt(padx-8, pady -8, 1); video_pt(padx-9, pady -9, 1); video_pt(padx-10, pady -10, 1); video_pt(padx-11, pady -11, 1); video_pt(padx-12, pady -12, 1); video_pt(padx-13, pady -13, 1); video_pt(padx-14, pady -14, 1); video_pt(padx-15, pady -15, 1); video_pt(padx-16, pady -16, 1); lineNumber = 7; erase_line1(); erase_line3(); erase_line4(); erase_line5(); erase_line6(); erase_line9(); } void erase_line7(void){ video_pt(padx, pady , 0); video_pt(padx-1, pady -1, 0); video_pt(padx-2, pady -2, 0); video_pt(padx-3, pady -3, 0); video_pt(padx-4, pady -4, 0); video_pt(padx-5, pady -5, 0); video_pt(padx-6, pady -6, 0); video_pt(padx-7, pady -7, 0); video_pt(padx-8, pady -8, 0); video_pt(padx-9, pady -9, 0); video_pt(padx-10, pady -10, 0); video_pt(padx-11, pady -11, 0); video_pt(padx-12, pady -12, 0); video_pt(padx-13, pady -13, 0); video_pt(padx-14, pady -14, 0); video_pt(padx-15, pady -15, 0); video_pt(padx-16, pady -16, 0); } void draw_line9(void){ video_pt(padx, pady , 1); video_pt(padx+1, pady -1, 1); video_pt(padx+2, pady -2, 1); video_pt(padx+3, pady -3, 1); video_pt(padx+4, pady -4, 1); video_pt(padx+5, pady -5, 1); video_pt(padx+6, pady -6, 1); video_pt(padx+7, pady -7, 1); video_pt(padx+8, pady -8, 1); video_pt(padx+9, pady -9, 1); video_pt(padx+10, pady -10, 1); video_pt(padx+11, pady -11, 1); video_pt(padx+12, pady -12, 1); video_pt(padx+13, pady -13, 1); video_pt(padx+14, pady -14, 1); video_pt(padx+15, pady -15, 1); video_pt(padx+16, pady -16, 1); lineNumber = 9; erase_line1(); erase_line3(); erase_line4(); erase_line5(); erase_line6(); erase_line7(); } void erase_line9(void){ video_pt(padx, pady , 0); video_pt(padx+1, pady -1, 0); video_pt(padx+2, pady -2, 0); video_pt(padx+3, pady -3, 0); video_pt(padx+4, pady -4, 0); video_pt(padx+5, pady -5, 0); video_pt(padx+6, pady -6, 0); video_pt(padx+7, pady -7, 0); video_pt(padx+8, pady -8, 0); video_pt(padx+9, pady -9, 0); video_pt(padx+10, pady -10, 0); video_pt(padx+11, pady -11, 0); video_pt(padx+12, pady -12, 0); video_pt(padx+13, pady -13, 0); video_pt(padx+14, pady -14, 0); video_pt(padx+15, pady -15, 0); video_pt(padx+16, pady -16, 0); } void draw_line1(void){ video_pt(padx, pady , 1); video_pt(padx, pady -1, 1); video_pt(padx, pady -2, 1); video_pt(padx-1, pady -3, 1); video_pt(padx-1, pady -4, 1); video_pt(padx-1, pady -5, 1); video_pt(padx-2, pady -6, 1); video_pt(padx-2, pady -7, 1); video_pt(padx-2, pady -8, 1); video_pt(padx-3, pady -9, 1); video_pt(padx-3, pady -10, 1); video_pt(padx-3, pady -11, 1); video_pt(padx-4, pady -12, 1); video_pt(padx-4, pady -13, 1); video_pt(padx-4, pady -14, 1); video_pt(padx-4, pady -15, 1); video_pt(padx-4, pady -16, 1); lineNumber = 1; erase_line3(); erase_line4(); erase_line5(); erase_line6(); erase_line7(); erase_line9(); } void erase_line1(void){ video_pt(padx, pady , 0); video_pt(padx, pady -1, 0); video_pt(padx, pady -2, 0); video_pt(padx-1, pady -3, 0); video_pt(padx-1, pady -4, 0); video_pt(padx-1, pady -5, 0); video_pt(padx-2, pady -6, 0); video_pt(padx-2, pady -7, 0); video_pt(padx-2, pady -8, 0); video_pt(padx-3, pady -9, 0); video_pt(padx-3, pady -10, 0); video_pt(padx-3, pady -11, 0); video_pt(padx-4, pady -12, 0); video_pt(padx-4, pady -13, 0); video_pt(padx-4, pady -14, 0); video_pt(padx-4, pady -15, 0); video_pt(padx-4, pady -16, 0); } void draw_line3(void){ video_pt(padx, pady , 1); video_pt(padx, pady -1, 1); video_pt(padx, pady -2, 1); video_pt(padx+1, pady -3, 1); video_pt(padx+1, pady -4, 1); video_pt(padx+1, pady -5, 1); video_pt(padx+2, pady -6, 1); video_pt(padx+2, pady -7, 1); video_pt(padx+2, pady -8, 1); video_pt(padx+3, pady -9, 1); video_pt(padx+3, pady -10, 1); video_pt(padx+3, pady -11, 1); video_pt(padx+4, pady -12, 1); video_pt(padx+4, pady -13, 1); video_pt(padx+4, pady -14, 1); video_pt(padx+4, pady -15, 1); video_pt(padx+4, pady -16, 1); lineNumber = 3; erase_line1(); erase_line4(); erase_line5(); erase_line6(); erase_line7(); erase_line9(); } void erase_line3(void){ video_pt(padx, pady , 0); video_pt(padx, pady -1, 0); video_pt(padx, pady -2, 0); video_pt(padx+1, pady -3, 0); video_pt(padx+1, pady -4, 0); video_pt(padx+1, pady -5, 0); video_pt(padx+2, pady -6, 0); video_pt(padx+2, pady -7, 0); video_pt(padx+2, pady -8, 0); video_pt(padx+3, pady -9, 0); video_pt(padx+3, pady -10, 0); video_pt(padx+3, pady -11, 0); video_pt(padx+4, pady -12, 0); video_pt(padx+4, pady -13, 0); video_pt(padx+4, pady -14, 0); video_pt(padx+4, pady -15, 0); video_pt(padx+4, pady -16, 0); } void draw_line4(void){ video_pt(padx, pady , 1); video_pt(padx-1, pady -1, 1); video_pt(padx-2, pady -2, 1); video_pt(padx-2, pady -3, 1); video_pt(padx-3, pady -4, 1); video_pt(padx-3, pady -5, 1); video_pt(padx-4, pady -6, 1); video_pt(padx-4, pady -7, 1); video_pt(padx-5, pady -8, 1); video_pt(padx-5, pady -9, 1); video_pt(padx-6, pady -10, 1); video_pt(padx-6, pady -11, 1); video_pt(padx-7, pady -12, 1); video_pt(padx-7, pady -13, 1); video_pt(padx-8, pady -14, 1); video_pt(padx-8, pady -15, 1); video_pt(padx-8, pady -16, 1); lineNumber = 4; erase_line1(); erase_line3(); erase_line5(); erase_line6(); erase_line7(); erase_line9(); } void erase_line4(void){ video_pt(padx, pady , 0); video_pt(padx-1, pady -1, 0); video_pt(padx-2, pady -2, 0); video_pt(padx-2, pady -3, 0); video_pt(padx-3, pady -4, 0); video_pt(padx-3, pady -5, 0); video_pt(padx-4, pady -6, 0); video_pt(padx-4, pady -7, 0); video_pt(padx-5, pady -8, 0); video_pt(padx-5, pady -9, 0); video_pt(padx-6, pady -10, 0); video_pt(padx-6, pady -11, 0); video_pt(padx-7, pady -12, 0); video_pt(padx-7, pady -13, 0); video_pt(padx-8, pady -14, 0); video_pt(padx-8, pady -15, 0); video_pt(padx-8, pady -16, 0); } void draw_line6(void){ video_pt(padx, pady , 1); video_pt(padx+1, pady -1, 1); video_pt(padx+2, pady -2, 1); video_pt(padx+2, pady -3, 1); video_pt(padx+3, pady -4, 1); video_pt(padx+3, pady -5, 1); video_pt(padx+4, pady -6, 1); video_pt(padx+4, pady -7, 1); video_pt(padx+5, pady -8, 1); video_pt(padx+5, pady -9, 1); video_pt(padx+6, pady -10, 1); video_pt(padx+6, pady -11, 1); video_pt(padx+7, pady -12, 1); video_pt(padx+7, pady -13, 1); video_pt(padx+8, pady -14, 1); video_pt(padx+8, pady -15, 1); video_pt(padx+8, pady -16, 1); lineNumber = 6; erase_line1(); erase_line3(); erase_line4(); erase_line5(); erase_line7(); erase_line9(); } void erase_line6(void){ video_pt(padx, pady , 0); video_pt(padx+1, pady -1, 0); video_pt(padx+2, pady -2, 0); video_pt(padx+2, pady -3, 0); video_pt(padx+3, pady -4, 0); video_pt(padx+3, pady -5, 0); video_pt(padx+4, pady -6, 0); video_pt(padx+4, pady -7, 0); video_pt(padx+5, pady -8, 0); video_pt(padx+5, pady -9, 0); video_pt(padx+6, pady -10, 0); video_pt(padx+6, pady -11, 0); video_pt(padx+7, pady -12, 0); video_pt(padx+7, pady -13, 0); video_pt(padx+8, pady -14, 0); video_pt(padx+8, pady -15, 0); video_pt(padx+8, pady -16, 0); } //******************************* void drawGoalie(char x,char y, char z) { //Use GoaliePos, argument z, in the switch 5 different goallie positions, standing, //flying right, flying left, //on the ground right, on the ground left... //Body //Stance 1 Standing if(z==1) { goalie_center_x=x; goalie_center_y=y; //Goalie Body video_pt(x+1,y-3,1); video_pt(x+2,y-3,1); video_pt(x-1,y-3,1); video_pt(x-2,y-3,1); video_pt(x+2,y-2,1); video_pt(x+3,y-2,1); video_pt(x+5,y-2,1); video_pt(x+6,y-2,1); video_pt(x+7,y-2,1); video_pt(x-2,y-2,1); video_pt(x-3,y-2,1); video_pt(x-5,y-2,1); video_pt(x-6,y-2,1); video_pt(x-7,y-2,1); video_pt(x+3,y-1,1); video_pt(x+4,y-1,1); video_pt(x+5,y-1,1); video_pt(x+6,y-1,1); video_pt(x-3,y-1,1); video_pt(x-4,y-1,1); video_pt(x-5,y-1,1); video_pt(x-6,y-1,1); video_pt(x-3,y,1); video_pt(x-4,y,1); video_pt(x-5,y,1); video_pt(x+3,y,1); video_pt(x+4,y,1); video_pt(x+5,y,1); video_pt(x+3,y+1,1); video_pt(x+3,y+2,1); video_pt(x+3,y+3,1); video_pt(x+2,y+4,1); video_pt(x+2,y+5,1); video_pt(x+2,y+6,1); video_pt(x-3,y+1,1); video_pt(x-3,y+2,1); video_pt(x-3,y+3,1); video_pt(x-2,y+4,1); video_pt(x-2,y+5,1); video_pt(x-2,y+6,1); video_pt(x,y+6,1); video_pt(x-3,y+7,1); video_pt(x-3,y+8,1); video_pt(x-3,y+9,1); video_pt(x-3,y+10,1); video_pt(x-3,y+11,1); video_pt(x-3,y+12,1); video_pt(x-3,y+13,1); video_pt(x-3,y+14,1); video_pt(x-3,y+15,1); video_pt(x-1,y+7,1); video_pt(x-1,y+8,1); video_pt(x-1,y+9,1); video_pt(x-1,y+10,1); video_pt(x-1,y+11,1); video_pt(x-1,y+12,1); video_pt(x-1,y+13,1); video_pt(x-1,y+14,1); video_pt(x-1,y+15,1); video_pt(x+1,y+7,1); video_pt(x+1,y+8,1); video_pt(x+1,y+9,1); video_pt(x+1,y+10,1); video_pt(x+1,y+11,1); video_pt(x+1,y+12,1); video_pt(x+1,y+13,1); video_pt(x+1,y+14,1); video_pt(x+1,y+15,1); video_pt(x+3,y+7,1); video_pt(x+3,y+8,1); video_pt(x+3,y+9,1); video_pt(x+3,y+10,1); video_pt(x+3,y+11,1); video_pt(x+3,y+12,1); video_pt(x+3,y+13,1); video_pt(x+3,y+14,1); video_pt(x+3,y+15,1); video_pt(x-4,y+16,1); video_pt(x-3,y+16,1); video_pt(x-2,y+16,1); video_pt(x-1,y+16,1); video_pt(x+4,y+16,1); video_pt(x+3,y+16,1); video_pt(x+2,y+16,1); video_pt(x+1,y+16,1); video_pt(x+6,y-3,1); video_pt(x+7,y-3,1); video_pt(x+8,y-3,1); video_pt(x-6,y-3,1); video_pt(x-7,y-3,1); video_pt(x-8,y-3,1); video_pt(x+7,y-4,1); video_pt(x+8,y-4,1); video_pt(x-7,y-4,1); video_pt(x-8,y-4,1); video_pt(x+7,y-5,1); video_pt(x+8,y-5,1); video_pt(x-7,y-5,1); video_pt(x-8,y-5,1); video_pt(x+2,y-1,1); video_pt(x+1,y,1); video_pt(x,y+1,1); video_pt(x-1,y+2,1); video_pt(x-2,y+3,1); //Goallie Head drawball(x,y-7,3); video_pt(x,y-4,1); } //Diving right if(z==2) { y=y+10; x=x+26; goalie_center_x=x; goalie_center_y=y; video_pt(x,y,1); drawball(x+6,y-2,3); video_pt(x+3,y-1,1); video_pt(x+3,y-2,1); video_pt(x+2,y-7,1); video_pt(x+2,y-6,1); video_pt(x+2,y-5,1); video_pt(x+2,y-4,1); video_pt(x+2,y-3,1); video_pt(x+2,y-2,1); video_pt(x+2,y,1); video_pt(x+2,y+1,1); video_pt(x+2,y+2,1); video_pt(x+2,y+3,1); video_pt(x+2,y+4,1); video_pt(x+3,y-7,1); video_pt(x+3,y-6,1); video_pt(x+4,y-7,1); video_pt(x+4,y-6,1); video_pt(x+5,y-7,1); video_pt(x+5,y-6,1); video_pt(x+3,y+3,1); video_pt(x+3,y+4,1); video_pt(x+3,y+5,1); video_pt(x+9,y+4,1); video_pt(x+8,y+4,1); video_pt(x+7,y+4,1); video_pt(x+6,y+4,1); video_pt(x+5,y+4,1); video_pt(x+4,y+4,1); video_pt(x+9,y+5,1); video_pt(x+8,y+5,1); video_pt(x+7,y+5,1); video_pt(x+6,y+5,1); video_pt(x+5,y+5,1); video_pt(x+4,y+5,1); video_pt(x+9,y+3,1); video_pt(x+10,y+3,1); video_pt(x+10,y+4,1); video_pt(x+10,y+5,1); video_pt(x+1,y-1,1); video_pt(x+1,y-3,1); video_pt(x+1,y-4,1); video_pt(x+1,y-5,1); video_pt(x+1,y-6,1); video_pt(x+1,y-7,1); video_pt(x+1,y+3,1); video_pt(x,y+3,1); video_pt(x,y-3,1); video_pt(x-1,y+1,1); video_pt(x-1,y-3,1); video_pt(x-1,y+3,1); video_pt(x-2,y-2,1); video_pt(x-2,y-3,1); video_pt(x-2,y+3,1); video_pt(x-2,y+2,1); video_pt(x-3,y-2,1); video_pt(x-3,y+2,1); video_pt(x-4,y-2,1); video_pt(x-4,y+2,1); video_pt(x-5,y-1,1); video_pt(x-5,y+2,1); video_pt(x-5,y+3,1); video_pt(x-6,y-1,1); video_pt(x-6,y+1,1); video_pt(x-6,y+2,1); video_pt(x-6,y+4,1); video_pt(x-7,y,1); video_pt(x-7,y-2,1); video_pt(x-7,y+3,1); video_pt(x-7,y+5,1); video_pt(x-8,y-1,1); video_pt(x-8,y-3,1); video_pt(x-8,y+2,1); video_pt(x-8,y+3,1); video_pt(x-8,y+5,1); video_pt(x-9,y-2,1); video_pt(x-9,y-4,1); video_pt(x-9,y+2,1); video_pt(x-9,y+4,1); video_pt(x-10,y-3,1); video_pt(x-10,y-5,1); video_pt(x-10,y+2,1); video_pt(x-10,y+4,1); video_pt(x-11,y-4,1); video_pt(x-11,y-5,1); video_pt(x-11,y-6,1); video_pt(x-11,y+2,1); video_pt(x-11,y+4,1); video_pt(x-12,y-4,1); video_pt(x-12,y-5,1); video_pt(x-12,y-6,1); video_pt(x-12,y-7,1); video_pt(x-12,y+2,1); video_pt(x-12,y+4,1); video_pt(x-13,y+2,1); video_pt(x-13,y+3,1); video_pt(x-13,y+4,1); video_pt(x-13,y+5,1); } //Diving left goalie if(z==3) { //Goalie Body y=y+10; x=x-26; goalie_center_x=x; goalie_center_y=y; video_pt(x,y,1); drawball(x-6,y-2,3); video_pt(x-3,y-1,1); video_pt(x-3,y-2,1); video_pt(x-2,y-7,1); video_pt(x-2,y-6,1); video_pt(x-2,y-5,1); video_pt(x-2,y-4,1); video_pt(x-2,y-3,1); video_pt(x-2,y-2,1); video_pt(x-2,y,1); video_pt(x-2,y+1,1); video_pt(x-2,y+2,1); video_pt(x-2,y+3,1); video_pt(x-2,y+4,1); video_pt(x-3,y-7,1); video_pt(x-3,y-6,1); video_pt(x-4,y-7,1); video_pt(x-4,y-6,1); video_pt(x-5,y-7,1); video_pt(x-5,y-6,1); video_pt(x-3,y+3,1); video_pt(x-3,y+4,1); video_pt(x-3,y+5,1); video_pt(x-9,y+4,1); video_pt(x-8,y+4,1); video_pt(x-7,y+4,1); video_pt(x-6,y+4,1); video_pt(x-5,y+4,1); video_pt(x-4,y+4,1); video_pt(x-9,y+5,1); video_pt(x-8,y+5,1); video_pt(x-7,y+5,1); video_pt(x-6,y+5,1); video_pt(x-5,y+5,1); video_pt(x-4,y+5,1); video_pt(x-9,y+3,1); video_pt(x-10,y+3,1); video_pt(x-10,y+4,1); video_pt(x-10,y+5,1); video_pt(x-1,y-1,1); video_pt(x-1,y-3,1); video_pt(x-1,y-4,1); video_pt(x-1,y-5,1); video_pt(x-1,y-6,1); video_pt(x-1,y-7,1); video_pt(x-1,y+3,1); video_pt(x,y+3,1); video_pt(x,y-3,1); video_pt(x+1,y+1,1); video_pt(x+1,y-3,1); video_pt(x+1,y+3,1); video_pt(x+2,y-2,1); video_pt(x+2,y-3,1); video_pt(x+2,y+3,1); video_pt(x+2,y+2,1); video_pt(x+3,y-2,1); video_pt(x+3,y+2,1); video_pt(x+4,y-2,1); video_pt(x+4,y+2,1); video_pt(x+5,y-1,1); video_pt(x+5,y+2,1); video_pt(x+5,y+3,1); video_pt(x+6,y-1,1); video_pt(x+6,y+1,1); video_pt(x+6,y+2,1); video_pt(x+6,y+4,1); video_pt(x+7,y,1); video_pt(x+7,y-2,1); video_pt(x+7,y+3,1); video_pt(x+7,y+5,1); video_pt(x+8,y-1,1); video_pt(x+8,y-3,1); video_pt(x+8,y+2,1); video_pt(x+8,y+3,1); video_pt(x+8,y+5,1); video_pt(x+9,y-2,1); video_pt(x+9,y-4,1); video_pt(x+9,y+2,1); video_pt(x+9,y+4,1); video_pt(x+10,y-3,1); video_pt(x+10,y-5,1); video_pt(x+10,y+2,1); video_pt(x+10,y+4,1); video_pt(x+11,y-4,1); video_pt(x+11,y-5,1); video_pt(x+11,y-6,1); video_pt(x+11,y+2,1); video_pt(x+11,y+4,1); video_pt(x+12,y-4,1); video_pt(x+12,y-5,1); video_pt(x+12,y-6,1); video_pt(x+12,y-7,1); video_pt(x+12,y+2,1); video_pt(x+12,y+4,1); video_pt(x+13,y+2,1); video_pt(x+13,y+3,1); video_pt(x+13,y+4,1); video_pt(x+13,y+5,1); }//end z==3 } void eraseGoalie(char x,char y, char z) { //Use GoaliePos, argument z, in the switch 5 different goallie positions, standing, //flying right, flying left, //on the ground right, on the ground left... //Body //Stance 1 Standing if(z==1) { //Goalie Body video_pt(x+1,y-3,0); video_pt(x+2,y-3,0); video_pt(x-1,y-3,0); video_pt(x-2,y-3,0); video_pt(x+2,y-2,0); video_pt(x+3,y-2,0); video_pt(x+5,y-2,0); video_pt(x+6,y-2,0); video_pt(x+7,y-2,0); video_pt(x-2,y-2,0); video_pt(x-3,y-2,0); video_pt(x-5,y-2,0); video_pt(x-6,y-2,0); video_pt(x-7,y-2,0); video_pt(x+3,y-1,0); video_pt(x+4,y-1,0); video_pt(x+5,y-1,0); video_pt(x+6,y-1,0); video_pt(x-3,y-1,0); video_pt(x-4,y-1,0); video_pt(x-5,y-1,0); video_pt(x-6,y-1,0); video_pt(x-3,y,0); video_pt(x-4,y,0); video_pt(x-5,y,0); video_pt(x+3,y,0); video_pt(x+4,y,0); video_pt(x+5,y,0); video_pt(x+3,y+1,0); video_pt(x+3,y+2,0); video_pt(x+3,y+3,0); video_pt(x+2,y+4,0); video_pt(x+2,y+5,0); video_pt(x+2,y+6,0); video_pt(x-3,y+1,0); video_pt(x-3,y+2,0); video_pt(x-3,y+3,0); video_pt(x-2,y+4,0); video_pt(x-2,y+5,0); video_pt(x-2,y+6,0); video_pt(x,y+6,0); video_pt(x-3,y+7,0); video_pt(x-3,y+8,0); video_pt(x-3,y+9,0); video_pt(x-3,y+10,0); video_pt(x-3,y+11,0); video_pt(x-3,y+12,0); video_pt(x-3,y+13,0); video_pt(x-3,y+14,0); video_pt(x-3,y+15,0); video_pt(x-1,y+7,0); video_pt(x-1,y+8,0); video_pt(x-1,y+9,0); video_pt(x-1,y+10,0); video_pt(x-1,y+11,0); video_pt(x-1,y+12,0); video_pt(x-1,y+13,0); video_pt(x-1,y+14,0); video_pt(x-1,y+15,0); video_pt(x+1,y+7,0); video_pt(x+1,y+8,0); video_pt(x+1,y+9,0); video_pt(x+1,y+10,0); video_pt(x+1,y+11,0); video_pt(x+1,y+12,0); video_pt(x+1,y+13,0); video_pt(x+1,y+14,0); video_pt(x+1,y+15,0); video_pt(x+3,y+7,0); video_pt(x+3,y+8,0); video_pt(x+3,y+9,0); video_pt(x+3,y+10,0); video_pt(x+3,y+11,0); video_pt(x+3,y+12,0); video_pt(x+3,y+13,0); video_pt(x+3,y+14,0); video_pt(x+3,y+15,0); video_pt(x-4,y+16,0); video_pt(x-3,y+16,0); video_pt(x-2,y+16,0); video_pt(x-1,y+16,0); video_pt(x+4,y+16,0); video_pt(x+3,y+16,0); video_pt(x+2,y+16,0); video_pt(x+1,y+16,0); video_pt(x+6,y-3,0); video_pt(x+7,y-3,0); video_pt(x+8,y-3,0); video_pt(x-6,y-3,0); video_pt(x-7,y-3,0); video_pt(x-8,y-3,0); video_pt(x+7,y-4,0); video_pt(x+8,y-4,0); video_pt(x-7,y-4,0); video_pt(x-8,y-4,0); video_pt(x+7,y-5,0); video_pt(x+8,y-5,0); video_pt(x-7,y-5,0); video_pt(x-8,y-5,0); video_pt(x+2,y-1,0); video_pt(x+1,y,0); video_pt(x,y+1,0); video_pt(x-1,y+2,0); video_pt(x-2,y+3,0); //Goallie Head eraseOldball(x,y-7,3); video_pt(x,y-4,0); } //diving right if(z==2) { y=y+10; x=x+26; video_pt(x,y,0); eraseOldball(x+6,y-2,3); video_pt(x+3,y-1,0); video_pt(x+3,y-2,0); video_pt(x+2,y-7,0); video_pt(x+2,y-6,0); video_pt(x+2,y-5,0); video_pt(x+2,y-4,0); video_pt(x+2,y-3,0); video_pt(x+2,y-2,0); video_pt(x+2,y,0); video_pt(x+2,y+1,0); video_pt(x+2,y+2,0); video_pt(x+2,y+3,0); video_pt(x+2,y+4,0); video_pt(x+3,y-7,0); video_pt(x+3,y-6,0); video_pt(x+4,y-7,0); video_pt(x+4,y-6,0); video_pt(x+5,y-7,0); video_pt(x+5,y-6,0); video_pt(x+3,y+3,0); video_pt(x+3,y+4,0); video_pt(x+3,y+5,0); video_pt(x+9,y+4,0); video_pt(x+8,y+4,0); video_pt(x+7,y+4,0); video_pt(x+6,y+4,0); video_pt(x+5,y+4,0); video_pt(x+4,y+4,0); video_pt(x+9,y+5,0); video_pt(x+8,y+5,0); video_pt(x+7,y+5,0); video_pt(x+6,y+5,0); video_pt(x+5,y+5,0); video_pt(x+4,y+5,0); video_pt(x+9,y+3,0); video_pt(x+10,y+3,0); video_pt(x+10,y+4,0); video_pt(x+10,y+5,0); video_pt(x+1,y-1,0); video_pt(x+1,y-3,0); video_pt(x+1,y-4,0); video_pt(x+1,y-5,0); video_pt(x+1,y-6,0); video_pt(x+1,y-7,0); video_pt(x+1,y+3,0); video_pt(x,y+3,0); video_pt(x,y-3,0); video_pt(x-1,y+1,0); video_pt(x-1,y-3,0); video_pt(x-1,y+3,0); video_pt(x-2,y-2,0); video_pt(x-2,y-3,0); video_pt(x-2,y+3,0); video_pt(x-2,y+2,0); video_pt(x-3,y-2,0); video_pt(x-3,y+2,0); video_pt(x-4,y-2,0); video_pt(x-4,y+2,0); video_pt(x-5,y-1,0); video_pt(x-5,y+2,0); video_pt(x-5,y+3,0); video_pt(x-6,y-1,0); video_pt(x-6,y+1,0); video_pt(x-6,y+2,0); video_pt(x-6,y+4,0); video_pt(x-7,y,0); video_pt(x-7,y-2,0); video_pt(x-7,y+3,0); video_pt(x-7,y+5,0); video_pt(x-8,y-1,0); video_pt(x-8,y-3,0); video_pt(x-8,y+2,0); video_pt(x-8,y+3,0); video_pt(x-8,y+5,0); video_pt(x-9,y-2,0); video_pt(x-9,y-4,0); video_pt(x-9,y+2,0); video_pt(x-9,y+4,0); video_pt(x-10,y-3,0); video_pt(x-10,y-5,0); video_pt(x-10,y+2,0); video_pt(x-10,y+4,0); video_pt(x-11,y-4,0); video_pt(x-11,y-5,0); video_pt(x-11,y-6,0); video_pt(x-11,y+2,0); video_pt(x-11,y+4,0); video_pt(x-12,y-4,0); video_pt(x-12,y-5,0); video_pt(x-12,y-6,0); video_pt(x-12,y-7,0); video_pt(x-12,y+2,0); video_pt(x-12,y+4,0); video_pt(x-13,y+2,0); video_pt(x-13,y+3,0); video_pt(x-13,y+4,0); video_pt(x-13,y+5,0); } //Diving left goalie if(z==3){ y=y+10; x=x-26; video_pt(x,y,0); eraseOldball(x-6,y-2,3); video_pt(x-3,y-1,0); video_pt(x-3,y-2,0); video_pt(x-2,y-7,0); video_pt(x-2,y-6,0); video_pt(x-2,y-5,0); video_pt(x-2,y-4,0); video_pt(x-2,y-3,0); video_pt(x-2,y-2,0); video_pt(x-2,y,0); video_pt(x-2,y+1,0); video_pt(x-2,y+2,0); video_pt(x-2,y+3,0); video_pt(x-2,y+4,0); video_pt(x-3,y-7,0); video_pt(x-3,y-6,0); video_pt(x-4,y-7,0); video_pt(x-4,y-6,0); video_pt(x-5,y-7,0); video_pt(x-5,y-6,0); video_pt(x-3,y+3,0); video_pt(x-3,y+4,0); video_pt(x-3,y+5,0); video_pt(x-9,y+4,0); video_pt(x-8,y+4,0); video_pt(x-7,y+4,0); video_pt(x-6,y+4,0); video_pt(x-5,y+4,0); video_pt(x-4,y+4,0); video_pt(x-9,y+5,0); video_pt(x-8,y+5,0); video_pt(x-7,y+5,0); video_pt(x-6,y+5,0); video_pt(x-5,y+5,0); video_pt(x-4,y+5,0); video_pt(x-9,y+3,0); video_pt(x-10,y+3,0); video_pt(x-10,y+4,0); video_pt(x-10,y+5,0); video_pt(x-1,y-1,0); video_pt(x-1,y-3,0); video_pt(x-1,y-4,0); video_pt(x-1,y-5,0); video_pt(x-1,y-6,0); video_pt(x-1,y-7,0); video_pt(x-1,y+3,0); video_pt(x,y+3,0); video_pt(x,y-3,0); video_pt(x+1,y+1,0); video_pt(x+1,y-3,0); video_pt(x+1,y+3,0); video_pt(x+2,y-2,0); video_pt(x+2,y-3,0); video_pt(x+2,y+3,0); video_pt(x+2,y+2,0); video_pt(x+3,y-2,0); video_pt(x+3,y+2,0); video_pt(x+4,y-2,0); video_pt(x+4,y+2,0); video_pt(x+5,y-1,0); video_pt(x+5,y+2,0); video_pt(x+5,y+3,0); video_pt(x+6,y-1,0); video_pt(x+6,y+1,0); video_pt(x+6,y+2,0); video_pt(x+6,y+4,0); video_pt(x+7,y,0); video_pt(x+7,y-2,0); video_pt(x+7,y+3,0); video_pt(x+7,y+5,0); video_pt(x+8,y-1,0); video_pt(x+8,y-3,0); video_pt(x+8,y+2,0); video_pt(x+8,y+3,0); video_pt(x+8,y+5,0); video_pt(x+9,y-2,0); video_pt(x+9,y-4,0); video_pt(x+9,y+2,0); video_pt(x+9,y+4,0); video_pt(x+10,y-3,0); video_pt(x+10,y-5,0); video_pt(x+10,y+2,0); video_pt(x+10,y+4,0); video_pt(x+11,y-4,0); video_pt(x+11,y-5,0); video_pt(x+11,y-6,0); video_pt(x+11,y+2,0); video_pt(x+11,y+4,0); video_pt(x+12,y-4,0); video_pt(x+12,y-5,0); video_pt(x+12,y-6,0); video_pt(x+12,y-7,0); video_pt(x+12,y+2,0); video_pt(x+12,y+4,0); video_pt(x+13,y+2,0); video_pt(x+13,y+3,0); video_pt(x+13,y+4,0); video_pt(x+13,y+5,0); } } //Procedure to calculate the distance...This procedure can be completely avoided to save //time and memory... float getDistance(char x) { //(63,200) ballcenter... float temp1; float temp2; switch (x) { case 0: return (float)(95); break; case 1: //(78,105) case -1://(48,105) temp1 = fix2float(multfix(int2fix(ballcentx-78),int2fix(ballcentx-78))); temp2= fix2float(multfix(int2fix(ballcenty-105),int2fix(ballcenty-105))); return fix2float(sqrtfix(float2fix(temp1+temp2))); break; case 2: //(93,105) case -2: //(33,105) temp1 = fix2float(multfix(int2fix(93-ballcentx),int2fix(93-ballcentx))); temp2 = fix2float(multfix(int2fix(ballcenty-105),int2fix(ballcenty-105))); return fix2float(sqrtfix(float2fix(temp1+temp2))); break; case -3://(18,105) case 3: //(108,105) temp1 = fix2float(multfix(int2fix(ballcentx-18),int2fix(ballcentx-18))); temp2 = fix2float(multfix(int2fix(ballcenty-105),int2fix(ballcenty-105))); return fix2float(sqrtfix(float2fix(temp1+temp2))); break; }//end switch... }//end get distance to the goal... //Procedure get time to reach the goal. int getTimetoGoal(char x, char y) { int dis; dis = getDistance(y); // y== keynum... return fix2float(divfix(int2fix(dis),int2fix(x))); // argument x is vx when procedure called... }//end getTimetoGoal // Procedure to simulate goal keeper movement. void moveGoalie(void) { if(keynum == -1 ||keynum == -2 ||keynum== -3) { if(random <= 180) { //70 percent chance for the correct side... goalpos = 3; } else if(random < 230 && random > 180) { goalpos=2;} //Wrong side 20 percent chance else { goalpos =1; } } //10 percent chance of goalie not moving at all... else if(keynum == 1||keynum == 2 ||keynum== 3 ){ if(random <=180) { goalpos = 2; }//70 percent chance for the correct side... else if(chance <230 && chance > 180){ //Wrong side goalpos=3; } else { goalpos =1; } } else { if(random <=70) { goalpos = 2; } else if(chance <140 && chance > 70) goalpos=3; else goalpos =1; } } //************************* //Procedure to compare positions of the goallie and the ball for a possible save. char getDistance_y(void) { signed char temp1; temp1 = abs(ballcenty)- abs(goalie_center_y) ; return temp1; } char getDistance_x(void) { signed char temp2; temp2 = abs(goalie_center_x - ballcentx); return temp2; } //*************************** //Scan the keypad void read(void) begin time2 = readMS; //PORTB = 0xff; butnum = 0; //get lower nibble DDRB = 0x0f; PORTB = 0xf0; delay_us(5); key = PINB; //get upper nibble DDRB = 0xf0; PORTB = 0x0f; delay_us(5); key = key | PINB; switch(PushState) begin case NoPush: if(key != 0xff) begin PushState = MaybePush; lastkey=key; end break; case MaybePush: if(key == lastkey) begin PushState = Pushed; PushFlag = 1; end else PushState = NoPush; break; case Pushed: if(key == lastkey){ PushState = Pushed; } else { PushState = MaybeNoPush; read_flag = 1; } break; case MaybeNoPush: if(key == lastkey) PushState = Pushed; else begin PushState = NoPush; PushFlag = 0; end break; end //find matching keycode in keytbl if(key != 0xff) { for (butnum=0; butnum distance_x) { vyp= -vyp; blocked = 1; } } else if(goalpos == 2) { distance_x = getDistance_x(); distance_y = getDistance_y(); if(distance_y <5 && distance_x < 10 ){ vyp = -vyp; blocked = 1; } } else if(goalpos == 3) { distance_x = getDistance_x(); distance_y = getDistance_y(); if(distance_y<5 && distance_x < 10){ vyp = -vyp; blocked = 1; } } } //================================== // set up the ports and timers void main(void) begin //init timer 1 to generate sync OCR1A = lineTime; //One NTSC line TCCR1B = 9; //full speed; clear-on-match TCCR1A = 0x00; //turn off pwm and oc lines TIMSK = 0x10; //enable interrupt T1 cmp PushState = NoPush; testtime=0; goalpos=1; play =0; state = menu1; g = 9.8; //DDRC =0xff; //Switch input //init ports DDRD = 0xf0; //video out and switches DDRC = 0x00; axy1 = 0; az1 = 0; axy = 0; az = 0; blocked = 0; keepermoved=0; //ADC enable, start conversion, not free running, //no interrupts, prescale 64 ->16e6/64=62.5kHz ADMUX=0b01100010; ADCSRA= 0b11000110; //for reading ADC task //D.5 is sync:1000 ohm + diode to 75 ohm resistor //D.6 is video:330 ohm + diode to 75 ohm resistor timer3 == 263; //initialize synch constants LineCount = 1; syncON = 0b00000000; syncOFF = 0b00100000; shotdone = 0; //Print "CORNELL" //video_puts(13,3,cu1); //Print "ECE476" //video_puts(65,3,cu2); //side lines #define width 126 //init software timer t=0; time=0; menutimer=0; framecount = 0; ballmove = 0; //init musical scale note = 0; musicT = 0; //use OC0 (pin B.3) for music //DDRB.3 = 1 ; DDRB = 0xff; //enable sleep mode MCUCR = 0b10000000; #asm ("sei"); //Initialize game variables padx =60; pady=221; ballcentx= 60; ballcenty=96; goalx = 63; goaly = 15; goaliex = 60; goaliey = 25; goalpos=1; goal = 0; //The following loop executes once/video line during lines //1-230, then does all of the frame-end processing while(1) begin //stall here until next line starts //sleep enable; mode=idle //use sleep to make entry into sync ISR uniform time #asm ("sleep"); //The following code executes during the vertical blanking //Code here can be as long as //a total of 60 lines x 63.5 uSec/line x 8 cycles/uSec if (LineCount==231) begin framecount++; random++; calculate++; if(calculate>=1) calculate = 1; //Play a note //TCCR0 bits: //bit 7 no force: //bit 3 CTC on: //bit 5,4 toggle OC0 pin //bit 6 no PWM //bit 2-0 prescaler 256 so 1 tick is 16 microsec if((musicT++) > 15) //each note 1/4 second begin musicT = 0; TCCR0 = 0; if (notes[note]>0) TCCR0 = 0b00011100 ; //not a rest OCR0 = notes[note++] ; if (note>18) note = 0; //test for end of scale end //update the second clock if (++t>59) begin t=0; time = time + 1; //sprintf(ts,"%05d",time); //video_putsmalls(92,93,ts); end //video_putchar(65,keytime,butnum); //================================== //Line Direction Initializer. //******Include debouncer******. //State Machine for menu and game, based on keypad or switches to some port... if(keytime==50) //poll the switches at every 40 frames. begin read(); if (butnum==4) keynum--; if (butnum==6) keynum ++; if(keynum >=3) keynum = 3; if(keynum <= -3) keynum = -3; // video_putchar(65,keytime,butnum); keytime=0; end//end if //Not used anymore if(st==150) begin swit = PINC; st=0; end //Bigger state machine switch (state) begin default://No button press. menu 1 SOCCERMANIA case menu1:{ if(menutimer<=1) video_puts(20,30,menu1a); if(framecount%10 == 0) { axy = axy1; az= az1; readADCs(); axy2 = abs(axy1 - axy); az2 = abs(az1-az); } if(menutimer>100) begin state= menu2; video_clear(); menutimer=0; end break; } //Menu2, the menu mode case menu2:{ if(menutimer==1) begin video_clear(); video_putsmalls(20,30,menu2a); video_putsmalls(20,50,menu2b); end read(); if(butnum == 1){ state = gamemode; video_clear();} if(butnum == 2){ state = credits; video_clear();} break; } //The game playing mode case gamemode: { // sprintf(tt1,"%02d",score); // video_puts(101,90,tt1); //switch the keynumber to draw the direction lines. switch (keynum){ case 0: //5 draw_line5(); break; case -1: //1 draw_line1(); break; case 1: //3 draw_line3(); break; case -2: //4 draw_line4(); break; case 2: //6 draw_line6(); break; case -3: //7 draw_line7(); break; case 3: //9 draw_line9(); break; } //increment fc counter if(shotdone == 1) { fc++; } //clear screen if(fc == 80){ video_clear(); } //Enter the initial state. //if enough time has passed after shotdone and screen is cleared return to initial state. if(init == 1 || fc ==100) { //reset variables fc = 0; ballcentx= 60; ballcenty=96; goalx = 63; goaly = 15; goaliex = 60; goaliey = 25; goalpos=1; keynum = 0; shotdone = 0; draw_line5(); if(goal==1) { goal = 0; score++; } //Draw the goal video_line(17,10,106,10,1); video_line(17,10,17,40,1); video_line(106,10,106,40,1); video_line(0,40,17,40,1); video_line(106,40,125,40,1); framecount = 0; init=0; //Draw the ball and the goallie. drawGoalie(goaliex,goaliey,goalpos); drawball(ballcentx,ballcenty,3); //video_putsmalls(80,80,s4); sprintf(tt2,"%01d",score); video_putsmalls(75,80,tt2); // video_putchar(85,85,score); } //Wait 30 frames before starting to sample ADC, poll every 10 frames. if(framecount>=30) { if(framecount%10 == 0) { axy = axy1; az= az1; readADCs(); axy2 = abs(axy1 - axy); az2 = abs(az1-az); } } //If acceleration is above a threshold go into calculation frame mode. if(axy2 >100 || az2 > 100) { play = 1; calculate = 0; axy22 = axy2>>10; // ADC/1024 conversion to a voltage ratio axy11 = az2>>10; vxy = fix2float(multfix(int2fix(axy22),float2fix(11.76))); // V = (ADC/1024)*1.5g*timeofcontact*4 vz = fix2float(multfix(int2fix(az22),float2fix(11.76))); // V = (ADC/1024)*1.5g*timeofcontact*4 vxp = fix2int(float2fix(vxy)); //floor vx into pixel speed vxp, vxp does not exceed 5 pixels per frame. vyp= vxp; //time = multfix(float2fix(getDistance(keynum)),float2fix(vx)); // time = multfix(time, float2fix(0.15)); //time is now a real time value 60 pixels represent 9m //Calculate dy... // temp1 = fix2float(multfix(int2fix(vy),time); // temp3 = fix2float(multfix(int2fix(time),time); // temp3 = fix2float(multfix(float2fix(temp3),float2fix(g)))); // temp2 =fix2float(multfix(int2fix(vy),temp3)>>1); // dy =40 - fix2int(temp1 - temp2); //scale dy so that it is a pixel number. //Alternative code... if(vzp == 1) dy = 35; if(vzp == 2) dy = 30; if(vzp == 3) dy = 25; if(vzp == 4) dy = 15; if(vzp >= 5) dy = 5; if(dy<40) dy = 35; if(dy<3) dy = 10; } //Calculation frame done, in the next frame enter playing mode, note in the ISR timed while(1) //line 231 calculate is not allowed to exceed 1. ISR line 261 and while(1) line231 are used for //frame counting incrementation. if (play ==1 && calculate == 1) { //if play enabled, update variables if even frame. if (framecount%2 == 0) { oldgoalpos=goalpos; //determine goallie movement moveGoalie(); //redraw goal if(ballcenty <= 43) { video_line(17,10,106,10,1); video_line(17,10,17,40,1); video_line(106,10,106,40,1); video_line(0,40,17,40,1); video_line(106,40,125,40,1); } //Check if shot has been saved. if(ballcenty < 60) { isGoalie(); } oldballx = ballcentx; oldbally = ballcenty; oldbutnum = butnum; //Check if ball is out of bounds if(ballcenty <=3) { ballcenty = 3; vyp=0; vxp = 0; shotdone = 1; video_putsmalls(20,90,s2); //Out play = 0; } if (ballcenty >90 && vyp <0) { ballcenty = 90; vyp = 0; vxp = 0; shotdone = 1; play = 0; } if(ballcentx<=3) { ballcentx = 3; vxp = 0; vyp = 0; //stop the ball. shotdone = 1; video_putsmalls(20,90,s2); //Out play = 0; } if(ballcentx>=122) { ballcentx = 122; vxp = 0; vyp = 0; //stop the ball. shotdone=1; video_putsmalls(20,90,s2); play = 0; } //if ball has reached its final value end play mode if (ballcenty <= dy) { play = 0; vyp = 0; vxp = 0; shotdone = 1; } //Check for saved, goal or out. if(blocked == 1 && (ballcenty >= 45 && vyp <0)) { play = 0; vyp = 0; vxp = 0; video_putsmalls(20,90,s3); //saved shotdone = 1; } if(play == 0) { if(ballcenty <= 40 && ballcenty >= 13 && ballcentx >= 15 && ballcentx <= 109) { play= 0; vyp = 0; vxp = 0; goal = 1; video_putsmalls(20,90,s1);// Goal shotdone=1; } // else{ // play = 0; // vyp = 0; // vxp = 0; // video_putsmalls(20,90,s2); //Out // shotdone = 1; // // } } //if ball has still not reached its destination, use direction vectors to update its ballcenter coordinates. if(ballcenty != dy && !(ballcenty == 60 && vyp < 0)) { switch (keynum) { default: ballcenty = ballcenty-(4*vyp); ballcentx= ballcentx; break; case 0: //5 ballcenty = ballcenty-(4*vyp); //ballcenty-(4*vy); ballcentx= ballcentx; break; case -1: //1 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx-(1*vxp); break; case 1: //3 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx+(1*vxp); break; case -2: //4 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx-(2*vxp); break; case 2: //6 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx+(2*vxp); break; case -3: //7 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx-(3*vxp); break; case 3: //9 ballcenty = ballcenty-(3*vyp); ballcentx= ballcentx+(3*vxp); break; } } if(goalx < 100) { oldgoalx = goalx; oldgoaly = goaly; goalx = goalx+2; } } //Erase old ball and goallie and draw the new ones. else if (framecount%2 == 1) { eraseOldball(oldballx, oldbally, 3); drawball(ballcentx,ballcenty,3); eraseGoalie(goaliex,goaliey,oldgoalpos); drawGoalie(goaliex,goaliey,goalpos); } //To check bouncing from the goalie... switch (keynum){ case 0: //5 draw_line5(); break; case -1: //1 draw_line1(); break; case 1: //3 draw_line3(); break; case -2: //4 draw_line4(); break; case 2: //6 draw_line6(); break; case -3: //7 draw_line7(); break; case 3: //9 draw_line9(); break; } } if(butnum == 2 || score == 5) { state = credits; video_clear(); } break; case credits : { video_puts(32,20,cc); video_putsmalls(32,40,menu3); video_putsmalls(60,40,menu3a); video_putsmalls(32,50,menu3b); video_putsmalls(60,50,menu3c); video_putsmalls(32,60,menu3d); video_putsmalls(60,60,menu3e); video_putsmalls(84,60,menu3f); video_putsmalls(32,70,menu3g); video_putsmalls(60,70,menu3h); break; } } end//end switch end //line 231 end //while end //end main