###########################################
## SDL Header
###########################################

scenario = "221_8class.sce"; 
no_logfile = true;
write_codes = true;
pulse_width = 20;
response_matching = simple_matching; # something to do with subject response
default_font_size = 20; 
active_buttons = 1; # total active buttons
button_codes = 1; # which button in active button list

begin;

###########################################
## SDL Stimuli
###########################################

bitmap { filename = "redPingu_L.jpg"; } red_pingu_L;
bitmap { filename = "redPingu_S.jpg"; } red_pingu_S;
bitmap { filename = "redKnoll_L.jpg"; } red_knoll_L;
bitmap { filename = "redKnoll_S.jpg"; } red_knoll_S;
bitmap { filename = "greenPingu_L.jpg"; } green_pingu_L;
bitmap { filename = "greenPingu_S.jpg"; } green_pingu_S;
bitmap { filename = "greenKnoll_L.jpg"; } green_knoll_L;
bitmap { filename = "greenKnoll_S.jpg"; } green_knoll_S;
bitmap { filename = "whiteCross_36.bmp"; } fix_point;
bitmap { filename = "grayBreak_dark.bmp"; } br;
bitmap { filename = "grayHalfBreak_dark.bmp"; } halfBr;
bitmap { filename = "allBlack.bmp"; } allBlack;
bitmap { filename = "end_36_dark.bmp"; } endExpt;

picture {
     bitmap red_pingu_L;
     x = 0; y = 0;
  } redPinguL;
  
picture {
     bitmap red_pingu_S;
     x = 0; y = 0;
  } redPinguS;
  
picture {
     bitmap red_knoll_L;
     x = 0; y = 0;
  } redKnollL;

picture {
     bitmap red_knoll_S;
     x = 0; y = 0;
  } redKnollS;
  
picture {
     bitmap green_pingu_L;
     x = 0; y = 0;
  } greenPinguL;

picture {
     bitmap green_pingu_S;
     x = 0; y = 0;
  } greenPinguS;
  
picture {
     bitmap green_knoll_L;
     x = 0; y = 0;
  } greenKnollL;

picture {
     bitmap green_knoll_S;
     x = 0; y = 0;
  } greenKnollS;

picture {
     bitmap fix_point;
     x = 0; y = 0;
  } fix;
  
picture {
     bitmap br;
     x = 0; y = 0;
  } break;
  
picture {
     bitmap halfBr;
     x = 0; y = 0;
  } halfwayBreak;
  
picture {
     bitmap allBlack;
     x = 0; y = 0;
} black;

picture {
     bitmap endExpt;
     x = 0; y = 0;
} endMsg;

###########################################
## SDL Trials
###########################################

trial {
	trial_duration = 1500;
	
   picture redPinguL;
   time=10;
   port_code=21;
   
	picture fix;
	time=760;
   
} stim21_trial;

trial {
	trial_duration = 1500;
	
   picture redPinguS;
   time=10;
   port_code=22;
   
	picture fix;
	time=760;
   
} stim22_trial;

trial {
	trial_duration = 1500;
	
   picture redKnollL;
   time=10;
   port_code=23;
   
	picture fix;
	time=760;
   
} stim23_trial;

trial {
	trial_duration = 1500;
	
   picture redKnollS;
   time=10;
   port_code=24;
   
	picture fix;
	time=760;
   
} stim24_trial;

trial {
	trial_duration = 1500;
	
   picture greenPinguL;
   time=10;
   port_code=25;
   
	picture fix;
	time=760;
   
} stim25_trial;

trial {
	trial_duration = 1500;
	
   picture greenPinguS;
   time=10;
   port_code=26;
   
	picture fix;
	time=760;
   
} stim26_trial;

trial {
	trial_duration = 1500;
	
   picture greenKnollL;
   time=10;
   port_code=27;
   
	picture fix;
	time=760;
   
} stim27_trial;

trial {
	trial_duration = 1500;
	
   picture greenKnollS;
   time=10;
   port_code=28;
   
	picture fix;
	time=760;
   
} stim28_trial;

trial {
	trial_duration = forever;
   trial_type = first_response;

   picture break;

   time = 0;
   target_button = 1; 
   port_code=254;

} break_trial;

trial {
	trial_duration = forever;
   trial_type = first_response;

   picture halfwayBreak;

   time = 0;
   target_button = 1; 
   port_code=0;

} halfway_break_trial;

trial {
	trial_duration = 500;
   picture black;
   time=0;   
} afterBreak_trial;

trial {
	trial_duration = forever;
   trial_type = first_response;

   picture endMsg;

   time = 0;
   target_button = 1; 
   port_code=0;

} end_trial;
 

###########################################
## PCL code
###########################################

begin_pcl;

int trialnum = 801; # set number of trials
#int trialnum=41; # for testing
int breaks=24;			# number of trials between breaks

array<int> int_trigger[trialnum];
int ti;
input_file in=new input_file;

in.open("stimArray_1.txt");
#in.open("stimArray_2.txt");
#in.open("stimArray_3.txt");
#in.open("stimArray_4.txt");
#in.open("stimArray_5.txt");
#in.open("stimArray_6.txt");
#in.open("stimArray_7.txt");
#in.open("stimArray_8.txt");
#in.open("stimArray_9.txt");
#in.open("stimArray_10.txt");
#in.open("stimArray_11.txt");
#in.open("stimArray_12.txt");
#in.open("tempArray.txt");				# for testing

int count=0;
loop until in.end_of_file() begin
	count=count+1;
	int_trigger[count]=in.get_int();
end;

int i=1;
loop until i>count begin
ti=int_trigger[i];
if (ti==21) then				# present one of the stimuli
	stim21_trial.present();
elseif (ti==22) then
	stim22_trial.present();
elseif (ti==23) then
	stim23_trial.present();
elseif (ti==24) then
	stim24_trial.present();
elseif (ti==25) then
	stim25_trial.present();
elseif (ti==26) then
	stim26_trial.present();
elseif (ti==27) then
	stim27_trial.present();
elseif (ti==28) then
	stim28_trial.present();
else
	end_trial.present();
end;

if (i==(trialnum/2)) then			# present breaks if necessary
	halfway_break_trial.present();
	afterBreak_trial.present();
elseif (mod(i,breaks)==0) then
	break_trial.present();
	afterBreak_trial.present();
end;
i=i+1;
end;
