00001 #include "drawConj.H" 00002 #include "defineConj.H" 00003 00004 int target_Pt3[2] = {4,6}; 00005 int target_Pt2[4] = {1,2,3,5}; 00006 int BO_L[2][2] = {{1,3},{0,2}}; 00007 int BO_Sq[2][2] = {{0,2},{1,3}}; 00008 int BO_Pt2[2][2] = {{0,2},{1,3}}; 00009 int BO_Shapes[2][12] = {{0,1,2,3,7,8,9,10,15,16,19,20}, 00010 {4,5,6,11,12,13,14,17,18,21,22,23}}; 00011 int target_dir; 00012 00013 int msleep(int ms) 00014 { 00015 struct timeval timeout; 00016 00017 timeout.tv_sec = ms / 1000; 00018 timeout.tv_usec = (ms % 1000) * 1000; 00019 if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &timeout) < 0) { 00020 perror("usleep"); 00021 return -1; 00022 } 00023 return 0; 00024 } 00025 00026 int search(int tar) 00027 { 00028 int i,j; 00029 00030 for(i=0;i<2;i++){ 00031 for(j=0;j<12;j++){ 00032 if(tar == BO_Shapes[i][j]){ 00033 return(i); 00034 } 00035 } 00036 } 00037 printf("Error\n tar = %d\n", tar); 00038 exit(0); 00039 } 00040 00041 00042 int selection(int tar) 00043 { 00044 if(tar >= 0 && tar < 4)return 0; //target is Square 00045 else if(tar >=4 && tar < 8)return 1; //target is New 00046 else return 2; //target is L shape 00047 } 00048 00049 void shuffle (int array[],int count) 00050 { 00051 int i,tmp,change,array2[400]; 00052 00053 srand((unsigned int)time(NULL)); 00054 00055 for (i = 0; i < count; ++i) 00056 array2[i]=array[i]; 00057 00058 for (i = 0; i < count; ++i) { 00059 change = rand() % count; 00060 tmp = array2[i]; 00061 array2[i] = array2[change]; 00062 array2[change] = tmp; 00063 00064 } 00065 00066 for( i = 0; i < count; i++ ){ 00067 array[i]=array2[i]; 00068 } 00069 } 00070 00071 void fragStimuli(int stimuli[],int target_stim,int target_BO) 00072 { 00073 00074 if(target_stim >= 0 && target_stim < 4){ //target is Square1 00075 //for(i=0;i<4;i++)stimuli[i]=3; 00076 if (target_BO == 0){ 00077 target_dir = 0; 00078 stimuli[1]=3; 00079 stimuli[3]=3; 00080 }else{ 00081 target_dir = 1; 00082 stimuli[0]=3; 00083 stimuli[2]=3; 00084 } 00085 }//else if(target_stim >=4 && target_stim < 8){ //target is Square2 00086 //for(i=4;i<7;i++)stimuli[i][target_type]=3; 00087 else if(target_stim == 4){target_dir = 1;stimuli[9]=3;} 00088 else if(target_stim == 5){target_dir = 0;stimuli[8]=3;} 00089 else if(target_stim == 6){target_dir = 3;stimuli[11]=3;} 00090 else if(target_stim == 7){target_dir = 2;stimuli[10]=3;} 00091 else if(target_stim == 8){target_dir = 0;stimuli[5]=3;} 00092 else if(target_stim == 9){target_dir = 1;stimuli[4]=3;} 00093 else if(target_stim == 10){target_dir = 2;stimuli[7]=3;} 00094 else if(target_stim == 11){target_dir = 3;stimuli[6]=3;} 00095 stimuli[target_stim] = 1; 00096 } 00097 00098 void SelectStimuli(int stimuli, float Lcolor, float x, float y, float times) 00099 { 00100 float Newcolor; 00101 00102 if(Lcolor ==1.0) Newcolor = 0.0; 00103 else Newcolor = 1.0; 00104 00105 switch (stimuli){ 00106 case 0: //Sq1. based on BO 00107 { 00108 draw_dist(1,x,y,Newcolor,times); 00109 }break; //end of "case 0:" 00110 case 1: //Sq1. based on BO right 00111 { 00112 draw_dist(0,x,y,Newcolor,times); 00113 }break; //end of "case 1:" 00114 case 2: //Sq1. based on BO right 00115 { 00116 draw_dist(3,x,y,Newcolor,times); 00117 }break; //end of "case 2:" 00118 case 3: //Sq1. based on BO right 00119 { 00120 draw_dist(2,x,y,Newcolor,times); 00121 }break; //end of "case 3:" 00122 case 4: 00123 { //New. based on BO left 00124 draw_L1(1,x,y,Newcolor,times); 00125 draw_New1(1,x,y,Lcolor,times); 00126 }break; //end of "case 4:" 00127 case 5:// New. based on BO left 00128 { 00129 draw_L1(0,x,y,Newcolor,times); 00130 draw_New1(0,x,y,Lcolor,times); 00131 }break; //end of "case 5:" 00132 case 6:// New. based on BO left 00133 { 00134 draw_L1(3,x,y,Newcolor,times); 00135 draw_New1(3,x,y,Lcolor,times); 00136 }break; //end of "case 6:" 00137 case 7: // New. based on BO left 00138 { 00139 draw_L1(2,x,y,Newcolor,times); 00140 draw_New1(2,x,y,Lcolor,times); 00141 }break; //end of "case 7:" 00142 case 8: // L. based on left 00143 { 00144 draw_Square1(0,x,y,Newcolor,times); 00145 draw_L1(0,x,y,Lcolor,times); 00146 }break; //end of "case 8:" 00147 case 9: // L. based on left 00148 { 00149 draw_Square1(1,x,y,Newcolor,times); 00150 draw_L1(1,x,y,Lcolor,times); 00151 }break; //end of "case 9:" 00152 case 10: // L. based on left 00153 { 00154 draw_Square1(2,x,y,Newcolor,times); 00155 draw_L1(2,x,y,Lcolor,times); 00156 }break; //end of "case 10:" 00157 case 11: // L. based on left 00158 { 00159 draw_Square1(3,x,y,Newcolor,times); 00160 draw_L1(3,x,y,Lcolor,times); 00161 }break; //end of "case 11:" 00162 default: 00163 { 00164 }break; 00165 } //end of "switch (stimuli)" 00166 00167 } 00168 00169 void Display_TargetShape(int target,int type) 00170 { 00171 glPushMatrix(); 00172 00173 switch (target){ 00174 case 0: 00175 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00176 shape_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00177 }break; 00178 case 1: 00179 { 00180 shape_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00181 }break; 00182 case 2: 00183 { 00184 shape_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00185 }break; 00186 } 00187 00188 glPopMatrix(); 00189 } 00190 00191 void Display_TargetCon(int BO, int target,int type) 00192 { 00193 glPushMatrix(); 00194 00195 if(BO == 0){//BO right 00196 switch (target){ 00197 case 0: 00198 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00199 blue_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00200 }break; 00201 case 1: 00202 { 00203 blue_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00204 }break; 00205 default: 00206 { 00207 blue_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00208 }break; 00209 } 00210 }else { //BO left 00211 switch (target){ 00212 case 0: 00213 {//void draw_Target_1(int type, float x, float y, float color, float times) //Square Shape 00214 red_Sq(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00215 }break; 00216 case 1: 00217 { 00218 red_New(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00219 }break; 00220 default: 00221 { 00222 red_L(type, 0.0, 0.0, 1.0, 2.0/(4.0*4.0)); 00223 }break; 00224 } 00225 } 00226 00227 glPopMatrix(); 00228 } 00229 00230 void Display_Blank(void) 00231 { 00232 glPushMatrix(); 00233 00234 glPopMatrix(); 00235 } 00236 00237 void Display_Con_L(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00238 int stimuli[], int array[], int place[][16], int trial, float hor[],float ver[],float color[]) 00239 /* target is L shape and BO */ 00240 { 00241 time_t timer; 00242 struct tm *t_st; 00243 int x; 00244 float noise_x,noise_y; 00245 int wait; 00246 int dist_location,dist_stim,dist_stim1,dist_stim2,dist_stim3; 00247 00248 dist_stim1 = 0;dist_stim2 = 0;dist_stim3 = 0; 00249 00250 time(&timer); 00251 t_st = localtime(&timer); 00252 00253 /***** Show only Fixation *****/ 00254 glClearColor(BGC, BGC, BGC, 0); 00255 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00256 Display_TargetCon(target_BO,target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00257 glutSwapBuffers(); 00258 00259 /***** Show Flash Fixation ******/ 00260 for(wait = 0 ; wait < 5 ; wait++){ 00261 glClearColor(BGC, BGC, BGC, 0); 00262 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00263 Display_TargetCon(target_BO,target_Shape,target_dir); 00264 glutSwapBuffers(); 00265 msleep(H_SLEEP); 00266 glClearColor(BGC, BGC, BGC, 0); 00267 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00268 Display_Blank(); 00269 glutSwapBuffers(); 00270 msleep(H_SLEEP); 00271 } 00272 00273 /*Draw Target*/ 00274 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00275 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00276 00277 glClearColor(BGC, BGC, BGC, 0); 00278 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00279 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00280 00281 switch (target_stim){ 00282 case (8): 00283 { 00284 dist_stim1 = 1; 00285 dist_stim2 = 5; 00286 dist_stim3 = 10; 00287 }break; 00288 case (9): 00289 { 00290 dist_stim1 = 0; 00291 dist_stim2 = 4; 00292 dist_stim3 = 11; 00293 }break; 00294 00295 case (10): 00296 { 00297 dist_stim1 = 3; 00298 dist_stim2 = 7; 00299 dist_stim3 = 8; 00300 }break; 00301 case (11): 00302 { 00303 dist_stim1 = 2; 00304 dist_stim2 = 6; 00305 dist_stim3 = 9; 00306 }break; 00307 } 00308 00309 for(x=0;x<4;x++){ 00310 for(;;){ 00311 dist_location = (t_st->tm_sec+rand())%16; 00312 if(array[dist_location]==0){ 00313 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00314 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00315 SelectStimuli(dist_stim1,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00316 array[dist_location]=2; 00317 place[trial][dist_location]=dist_stim1; 00318 break; 00319 } 00320 } 00321 } 00322 00323 for(x=0;x<2;x++){ 00324 for(;;){ 00325 dist_location = (t_st->tm_sec+rand())%16; 00326 if(array[dist_location]==0){ 00327 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00328 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00329 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00330 array[dist_location]=2; 00331 place[trial][dist_location]=dist_stim2; 00332 break; 00333 } 00334 } 00335 } 00336 00337 for(x=0;x<2;x++){ //New 00338 for(;;){ 00339 dist_location = (t_st->tm_sec+rand())%16; 00340 dist_stim = ((t_st->tm_sec+rand())%4)+4; 00341 //dist_type = (t_st->tm_sec+rand())%TYPE; 00342 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 == target_BO){ 00343 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00344 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00345 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00346 array[dist_location]=2; 00347 place[trial][dist_location]=dist_stim; 00348 break; 00349 } 00350 } 00351 } 00352 00353 for(x=0;x<4;x++){ //L 00354 for(;;){ 00355 dist_location = (t_st->tm_sec+rand())%16; 00356 dist_stim = ((t_st->tm_sec+rand())%4)+8; 00357 //dist_type = (t_st->tm_sec+rand())%TYPE; 00358 if(array[dist_location]==0 && stimuli[dist_stim]==0 /*&& dist_stim%2 == target_BO*/){ 00359 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00360 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00361 SelectStimuli(dist_stim3,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00362 array[dist_location]=2; 00363 place[trial][dist_location]=dist_stim; 00364 break; 00365 } 00366 } 00367 } 00368 00369 for(x=0;x<3;x++){//square 00370 for(;;){ 00371 dist_location = (t_st->tm_sec+rand())%16; 00372 dist_stim = (t_st->tm_sec+rand())%4; 00373 //dist_type = (t_st->tm_sec+rand())%TYPE; 00374 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 != target_BO){ 00375 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00376 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00377 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00378 array[dist_location]=2; 00379 place[trial][dist_location]=dist_stim; 00380 break; 00381 } 00382 } 00383 } 00384 //Display_TargetCon(target_BO,target_Shape,target_dir); 00385 glutSwapBuffers(); 00386 } 00387 00388 void Display_Con_Sq(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00389 int stimuli[], int array[], int place[][16], int trial, float hor[],float ver[],float color[]) 00390 /* target is L shape and BO */ 00391 { 00392 time_t timer; 00393 struct tm *t_st; 00394 int x; 00395 float noise_x,noise_y; 00396 int wait; 00397 int dist_location,dist_stim; 00398 00399 00400 time(&timer); 00401 t_st = localtime(&timer); 00402 00403 /***** Show only Fixation *****/ 00404 glClearColor(BGC, BGC, BGC, 0); 00405 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00406 Display_TargetCon(target_BO,target_Shape,target_type);//Display_TargetCon(int BO, int target,int type) 00407 glutSwapBuffers(); 00408 00409 00410 /***** Show Flash Fixation ******/ 00411 for(wait = 0 ; wait < 5 ; wait++){ 00412 glClearColor(BGC, BGC, BGC, 0); 00413 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00414 Display_TargetCon(target_BO,target_Shape,target_type); 00415 glutSwapBuffers(); 00416 msleep(H_SLEEP); 00417 glClearColor(BGC, BGC, BGC, 0); 00418 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00419 Display_Blank(); 00420 glutSwapBuffers(); 00421 msleep(H_SLEEP); 00422 } 00423 00424 /*Draw Target*/ 00425 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00426 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00427 00428 glClearColor(BGC, BGC, BGC, 0); 00429 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00430 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00431 //dist_type = target_type; 00432 00433 for(x=0;x<5;x++){//square 00434 for(;;){ 00435 dist_location = (t_st->tm_sec+rand())%16; 00436 dist_stim = (t_st->tm_sec+rand())%4; 00437 //dist_type = (t_st->tm_sec+rand())%TYPE; 00438 if(array[dist_location]==0 && stimuli[dist_stim]==0){ 00439 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00440 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00441 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00442 array[dist_location]=2; 00443 place[trial][dist_location]=dist_stim; 00444 break; 00445 } 00446 } 00447 } 00448 00449 for(x=0;x<5;x++){ //New 00450 for(;;){ 00451 dist_location = (t_st->tm_sec+rand())%16; 00452 dist_stim = ((t_st->tm_sec+rand())%4)+4; 00453 //dist_type = (t_st->tm_sec+rand())%TYPE; 00454 if(array[dist_location]==0 && stimuli[dist_stim]==0){ 00455 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00456 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00457 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00458 array[dist_location]=2; 00459 place[trial][dist_location]=dist_stim; 00460 break; 00461 } 00462 } 00463 } 00464 00465 for(x=0;x<5;x++){ //L 00466 for(;;){ 00467 dist_location = (t_st->tm_sec+rand())%16; 00468 dist_stim = ((t_st->tm_sec+rand())%4)+8; 00469 //dist_type = (t_st->tm_sec+rand())%TYPE; 00470 if(array[dist_location]==0 && stimuli[dist_stim]==0 && dist_stim%2 == target_BO){ 00471 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00472 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00473 SelectStimuli(dist_stim,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00474 array[dist_location]=2; 00475 place[trial][dist_location]=dist_stim; 00476 break; 00477 } 00478 } 00479 } 00480 00481 //Display_TargetCon(target_BO,target_Shape,target_type); 00482 glutSwapBuffers(); 00483 } 00484 00485 void Display_Con_New(int target_BO, int target_Shape,int target_stim,int target_type,int target_location, 00486 int stimuli[], int array[], int place[][16],int trial,float hor[],float ver[],float color[]) 00487 /* target is New shape and BO */ 00488 { 00489 time_t timer; 00490 struct tm *t_st; 00491 int x; 00492 float noise_x,noise_y; 00493 int i,wait; 00494 int dist_location,dist_stim1,dist_stim2; 00495 00496 dist_stim1 = 0;dist_stim2 = 0; 00497 00498 time(&timer); 00499 t_st = localtime(&timer); 00500 00501 /***** Show only Fixation *****/ 00502 glClearColor(BGC, BGC, BGC, 0); 00503 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00504 Display_TargetCon(target_BO,target_Shape,target_dir);//Display_TargetCon(int BO, int target,int type) 00505 glutSwapBuffers(); 00506 00507 /***** Show Flash Fixation ******/ 00508 for(wait = 0 ; wait < 5 ; wait++){ 00509 glClearColor(BGC, BGC, BGC, 0); 00510 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00511 Display_TargetCon(target_BO,target_Shape,target_dir); 00512 glutSwapBuffers(); 00513 msleep(H_SLEEP); 00514 glClearColor(BGC, BGC, BGC, 0); 00515 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00516 Display_Blank(); 00517 glutSwapBuffers(); 00518 msleep(H_SLEEP); 00519 } 00520 00521 /*Draw Target*/ 00522 noise_x = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00523 noise_y = ((t_st->tm_sec+rand())%11-5.0)/100.0; 00524 glClearColor(BGC, BGC, BGC, 0); 00525 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00526 SelectStimuli(target_stim,color[target_location],hor[target_location]+noise_x,ver[target_location]+noise_y,2.0/(4.0*4.0)); 00527 //void SelectStimuli(int stimuli, int type, float Lcolor, float x, float y, float times) 00528 00529 switch (target_stim){ 00530 case (4): 00531 { 00532 dist_stim1 = 9; 00533 }break; 00534 case (5): 00535 { 00536 dist_stim1 = 8; 00537 }break; 00538 case (6): 00539 { 00540 dist_stim1 = 11; 00541 }break; 00542 case (7): 00543 { 00544 dist_stim1 = 10; 00545 }break; 00546 } 00547 00548 for(i = 0 ;i < 4; i++){ //same shape 00549 for(;;){ 00550 dist_location = (t_st->tm_sec+rand())%16; 00551 if(array[dist_location]==0){ 00552 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00553 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00554 SelectStimuli(dist_stim1,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00555 array[dist_location]=2; 00556 place[trial][dist_location]=dist_stim1; 00557 break; 00558 } 00559 } 00560 } 00561 00562 for(x=0;x<4;x++){//New 00563 for(;;){ 00564 dist_location = (t_st->tm_sec+rand())%16; 00565 dist_stim2 = 4+(t_st->tm_sec+rand())%4; 00566 //dist_type = (t_st->tm_sec+rand())%TYPE; 00567 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2%2 != target_BO){ 00568 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00569 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00570 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00571 array[dist_location]=2; 00572 place[trial][dist_location]=dist_stim2; 00573 break; 00574 } 00575 } 00576 } 00577 00578 for(x=0;x<3;x++){//L 00579 for(;;){ 00580 dist_location = (t_st->tm_sec+rand())%16; 00581 dist_stim2 = 8+(t_st->tm_sec+rand())%4; 00582 //dist_type = (t_st->tm_sec+rand())%TYPE; 00583 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2 != dist_stim1){ 00584 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00585 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00586 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00587 array[dist_location]=2; 00588 place[trial][dist_location]=dist_stim2; 00589 break; 00590 } 00591 } 00592 } 00593 00594 for(x=0;x<4;x++){//square 00595 for(;;){ 00596 dist_location = (t_st->tm_sec+rand())%16; 00597 dist_stim2 = (t_st->tm_sec+rand())%4; 00598 //dist_type = (t_st->tm_sec+rand())%TYPE; 00599 if(array[dist_location]==0 && stimuli[dist_stim2]==0 && dist_stim2 != dist_stim1){ 00600 noise_x = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00601 noise_y = (((t_st->tm_sec+rand())%11)-5.0)/100.0; 00602 SelectStimuli(dist_stim2,color[dist_location],hor[dist_location]+noise_x,ver[dist_location]+noise_y,2.0/(4.0*4.0)); 00603 array[dist_location]=2; 00604 place[trial][dist_location]=dist_stim2; 00605 break; 00606 } 00607 } 00608 } 00609 //Display_TargetCon(target_BO,target_Shape,target_dir); 00610 glutSwapBuffers(); 00611 } 00612 00613 void Display_Conjunction(int target_BO, int target_Shape,int target_stim,int target_type, 00614 int target_location, int stimuli[], int array[], int place[][16], int trial, 00615 float hor[],float ver[],float color[]) 00616 { 00617 if(target_Shape == 0){ //target is Square 00618 Display_Con_Sq(target_BO, target_Shape,target_stim,target_type,target_location,stimuli, 00619 array,place,trial,hor,ver,color); 00620 }else if(target_Shape == 1){ //target is Pt2 00621 Display_Con_New(target_BO, target_Shape,target_stim,target_type,target_location,stimuli, 00622 array,place,trial,hor,ver,color); 00623 }else if(target_Shape == 2){ //target is L shape 00624 Display_Con_L(target_BO, target_Shape,target_stim,target_type,target_location,stimuli, 00625 array,place,trial,hor,ver,color); 00626 } 00627 } 00628 00629 void Display_Calibration(int state_calib, int calib[9]) 00630 { 00631 int i,check; 00632 time_t timer; 00633 struct tm *t_st; 00634 00635 time(&timer); 00636 t_st = localtime(&timer); 00637 //printf("state_calib = %d\n",state_calib); 00638 00639 if(state_calib == 0 || state_calib == 2){ 00640 glClearColor(BGC, BGC, BGC, 0); 00641 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00642 Display_Fixation(); 00643 glutSwapBuffers(); 00644 } 00645 else if(state_calib == 1){ 00646 glClearColor(BGC, BGC, BGC, 0); 00647 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00648 //Display_Blank(); 00649 Display_Fixation(); 00650 glutSwapBuffers(); 00651 msleep(F_SLEEP); 00652 glClearColor(BGC, BGC, BGC, 0); 00653 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00654 Display_CalibPoints(); 00655 glutSwapBuffers(); 00656 }else if(state_calib >= 3 && state_calib <= 11){ 00657 for(;;){ 00658 check = ((t_st->tm_sec+rand())%9); 00659 if(calib[check]==0){ 00660 calib[check]=1; 00661 break; 00662 } 00663 } 00664 00665 for(i=0;i<5;i++){ 00666 msleep(CALIB); 00667 glClearColor(BGC, BGC, BGC, 0); 00668 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00669 Display_Blank(); 00670 glutSwapBuffers(); 00671 msleep(CALIB); 00672 glClearColor(BGC, BGC, BGC, 0); 00673 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00674 Display_Fixation(); 00675 glutSwapBuffers(); 00676 } 00677 //printf("state_calib = %d\n",state_calib); 00678 switch (check){ 00679 case 0:{ 00680 for(i=0;i<5;i++){ 00681 //msleep(CALIB); 00682 glClearColor(BGC, BGC, BGC, 0); 00683 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00684 //Display_Fixation(); 00685 Display_Calib1(); 00686 glutSwapBuffers(); 00687 msleep(CALIB); 00688 glClearColor(BGC, BGC, BGC, 0); 00689 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00690 Display_Blank(); 00691 //Display_Fixation(); 00692 glutSwapBuffers(); 00693 msleep(CALIB); 00694 } 00695 break; 00696 } 00697 case 1:{ 00698 for(i=0;i<5;i++){ 00699 //msleep(CALIB); 00700 glClearColor(BGC, BGC, BGC, 0); 00701 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00702 Display_Calib2(); 00703 //Display_Fixation(); 00704 glutSwapBuffers(); 00705 msleep(CALIB); 00706 glClearColor(BGC, BGC, BGC, 0); 00707 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00708 Display_Blank(); 00709 //Display_Fixation(); 00710 glutSwapBuffers(); 00711 msleep(CALIB); 00712 } 00713 break; 00714 } 00715 case 2:{ 00716 for(i=0;i<5;i++){ 00717 //msleep(CALIB); 00718 glClearColor(BGC, BGC, BGC, 0); 00719 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00720 Display_Calib3(); 00721 //Display_Fixation(); 00722 glutSwapBuffers(); 00723 msleep(CALIB); 00724 glClearColor(BGC, BGC, BGC, 0); 00725 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00726 Display_Blank(); 00727 //Display_Fixation(); 00728 glutSwapBuffers(); 00729 msleep(CALIB); 00730 } 00731 break; 00732 } 00733 case 3:{ 00734 for(i=0;i<5;i++){ 00735 //msleep(CALIB); 00736 glClearColor(BGC, BGC, BGC, 0); 00737 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00738 Display_Calib4(); 00739 //Display_Fixation(); 00740 glutSwapBuffers(); 00741 msleep(CALIB); 00742 glClearColor(BGC, BGC, BGC, 0); 00743 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00744 Display_Blank(); 00745 //Display_Fixation(); 00746 glutSwapBuffers(); 00747 msleep(CALIB); 00748 } 00749 break; 00750 } 00751 case 4:{ 00752 for(i=0;i<5;i++){ 00753 //msleep(CALIB); 00754 glClearColor(BGC, BGC, BGC, 0); 00755 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00756 Display_Calib5(); 00757 //Display_Fixation(); 00758 glutSwapBuffers(); 00759 msleep(CALIB); 00760 glClearColor(BGC, BGC, BGC, 0); 00761 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00762 Display_Blank(); 00763 //Display_Fixation(); 00764 glutSwapBuffers(); 00765 msleep(CALIB); 00766 } 00767 break; 00768 } 00769 case 5:{ 00770 for(i=0;i<5;i++){ 00771 //msleep(CALIB); 00772 glClearColor(BGC, BGC, BGC, 0); 00773 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00774 Display_Calib6(); 00775 //Display_Fixation(); 00776 glutSwapBuffers(); 00777 msleep(CALIB); 00778 glClearColor(BGC, BGC, BGC, 0); 00779 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00780 Display_Blank(); 00781 //Display_Fixation(); 00782 glutSwapBuffers(); 00783 msleep(CALIB); 00784 } 00785 break; 00786 } 00787 case 6:{ 00788 for(i=0;i<5;i++){ 00789 //msleep(CALIB); 00790 glClearColor(BGC, BGC, BGC, 0); 00791 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00792 Display_Calib7(); 00793 //Display_Fixation(); 00794 glutSwapBuffers(); 00795 msleep(CALIB); 00796 glClearColor(BGC, BGC, BGC, 0); 00797 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00798 Display_Blank(); 00799 //Display_Fixation(); 00800 glutSwapBuffers(); 00801 msleep(CALIB); 00802 } 00803 break; 00804 } 00805 case 7:{ 00806 for(i=0;i<5;i++){ 00807 //msleep(CALIB); 00808 glClearColor(BGC, BGC, BGC, 0); 00809 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00810 Display_Calib8(); 00811 //Display_Fixation(); 00812 glutSwapBuffers(); 00813 msleep(CALIB); 00814 glClearColor(BGC, BGC, BGC, 0); 00815 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00816 Display_Blank(); 00817 //Display_Fixation(); 00818 glutSwapBuffers(); 00819 msleep(CALIB); 00820 } 00821 break; 00822 } 00823 case 8:{ 00824 for(i=0;i<5;i++){ 00825 //msleep(CALIB); 00826 glClearColor(BGC, BGC, BGC, 0); 00827 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00828 Display_Calib9(); 00829 //Display_Fixation(); 00830 glutSwapBuffers(); 00831 msleep(CALIB); 00832 glClearColor(BGC, BGC, BGC, 0); 00833 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00834 Display_Blank(); 00835 //Display_Fixation(); 00836 glutSwapBuffers(); 00837 msleep(CALIB); 00838 } 00839 break; 00840 } 00841 default:break; 00842 } 00843 glClearColor(BGC, BGC, BGC, 0); 00844 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00845 //Display_Blank(); 00846 Display_Fixation(); 00847 glutSwapBuffers(); 00848 }else if(state_calib == 12){ 00849 glClearColor(BGC, BGC, BGC, 0); 00850 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00851 //Display_Blank(); 00852 Display_Fixation(); 00853 glutSwapBuffers(); 00854 msleep(F_SLEEP); 00855 glClearColor(BGC, BGC, BGC, 0); 00856 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00857 Display_PointsF(); 00858 glutSwapBuffers(); 00859 } 00860 }