
/* Generated by Interface Builder */

#import "S3Setup.h"

const char *portSetupString1 = "F0,00,00,16,12,00,";
const char *setupString2 = ",F7";
const char *fcSetupString1   = "F0,00,00,16,13,00,";

@implementation S3Setup

- appDidInit:sender
{
	[fcChanFormCell setIntValue:fcChan];
	return self;
}

- init
{
	mask = 0x00;
	fcChan = 15;
	theNote = [[Note alloc] init];
	midi = [Midi new];
	[midi open];
	[midi run];
	sprintf(maskChars,"%x%x",((mask & 0xf0) >> 4),(mask & 0x0f));
	
	return self;
}

- sendIt:sender
{
	int i;
	char theString[23];

	mask = 0;
	for(i=0; i<6; i++)
		mask = mask + (mask_array[5-i] << i);
	sprintf(maskChars,"%x%x",((mask & 0xf0) >> 4),(mask & 0x0f));
	sprintf(theString,"%s%s%s",portSetupString1,maskChars,setupString2);
	printf("%s\n",theString);
	[theNote setPar:MK_sysExclusive toString:theString];
	[[midi channelNoteReceiver:0] receiveNote:theNote];

	sprintf(fcChanChars,"%x%x",((fcChan & 0xf0) >> 4),(fcChan & 0x0f));
	sprintf(theString,"%s%s%s",fcSetupString1,fcChanChars,setupString2);
	printf("%s\n",theString);
	[theNote setPar:MK_sysExclusive toString:theString];
	[[midi channelNoteReceiver:0] receiveNote:theNote];
	return self;
}

- doPort1:sender
{
	mask_array[0] = ![sender selectedRow];
	
	return self;
}

- doPort2:sender
{
	mask_array[1] = ![sender selectedRow];
	
   return self;
}

- doPort3:sender
{
	mask_array[2] = ![sender selectedRow];
	
    return self;
}

- doPort4:sender
{
	mask_array[3] = ![sender selectedRow];
	
    return self;
}

- doPort5:sender
{
	mask_array[4] = ![sender selectedRow];
	
    return self;
}

- doPort6:sender
{
	mask_array[5] = ![sender selectedRow];
	
	return self;
}

- doFCChan:sender
{
	fcChan = [sender intValue];
    return self;
}



@end
