| version 1.1, 2003/10/31 16:55:06 | version 1.3, 2004/03/15 05:06:02 | 
| Line 10 | Line 10 | 
 | #include "np2.h" | #include "np2.h" | 
 | #include "pccore.h" | #include "pccore.h" | 
 | #include "sysmng.h" | #include "sysmng.h" | 
 |  | #include "dialog.h" | 
 | #include "dialogutils.h" | #include "dialogutils.h" | 
 | #include "midiopt.h" | #include "midiopt.h" | 
 |  | #include "dipswbmp.h" | 
 |  |  | 
 | #define setControlValue(a,b,c)          SetControl32BitValue(getControlRefByID(a,b,midiWin),c) | #define setControlValue(a,b,c)          SetControl32BitValue(getControlRefByID(a,b,midiWin),c) | 
 | #define getMenuValue                            (GetControl32BitValue(getControlRefByID(cmd.commandID,0,midiWin))-1) | #define getMenuValue                            (GetControl32BitValue(getControlRefByID(cmd.commandID,0,midiWin))-1) | 
 |  |  | 
 | static WindowRef        midiWin; | static WindowRef        midiWin; | 
 | static BYTE                     mpu = 0; | static BYTE                     mpu = 0; | 
 |  | static COMCFG           mpucfg; | 
 |  |  | 
 |  | extern const char cmmidi_midimapper[]; | 
 |  | extern char cmmidi_vermouth[]; | 
 |  | extern const char *cmmidi_mdlname[]; | 
 |  |  | 
 |  | static const char *midiout_name[3] = {"", cmmidi_midimapper, cmmidi_vermouth}; | 
 |  |  | 
 |  | static UINT module2number(const char *module) { | 
 |  |  | 
 |  | UINT    i; | 
 |  |  | 
 |  | for (i=0; i<12; i++) { | 
 |  | if (!milstr_extendcmp(module, cmmidi_mdlname[i])) { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | return(i); | 
 |  | } | 
 |  |  | 
 |  | static void setMIMPIFilename(void) { | 
 |  | ControlRef  conRef = NULL; | 
 |  |  | 
 |  | conRef = getControlRefByID('mnam', 0, midiWin); | 
 |  | SetControlData(conRef, kControlNoPart, kControlStaticTextTextTag, strlen(mpucfg.def), mpucfg.def); | 
 |  | Draw1Control(conRef); | 
 |  | } | 
 |  |  | 
 |  |  | 
 | static void setMPUs(void) { | static void setMPUs(void) { | 
 |  | int             data = 1; | 
 |  | UINT    i; | 
 |  |  | 
 | setControlValue('MPio', 0, ((mpu >> 4) & 15)+1); | setControlValue('MPio', 0, ((mpu >> 4) & 15)+1); | 
 | setControlValue('MPin', 0, (mpu & 3)+1); | setControlValue('MPin', 0, (mpu & 3)+1); | 
 |  |  | 
 |  | if (!milstr_cmp(mpucfg.mout, cmmidi_midimapper)) { | 
 |  | data = 2; | 
 |  | } | 
 |  | #if defined(VERMOUTH_LIB) | 
 |  | else if (!milstr_cmp(mpucfg.mout, cmmidi_vermouth)) { | 
 |  | data = 3; | 
 |  | } | 
 |  | #endif | 
 |  | setControlValue('mido', 0, data); | 
 |  | setControlValue('midi', 0, 1);//Not available | 
 |  | i = module2number(mpucfg.mdl); | 
 |  | setControlValue('midm', 0, i+1); | 
 |  |  | 
 |  | setControlValue('usem', 0, mpucfg.def_en); | 
 |  | setMIMPIFilename(); | 
 |  |  | 
 |  | PicHandle   pict; | 
 |  | ControlRef  disp = getControlRefByID('BMP ', 0, midiWin); | 
 |  | setbmp(dipswbmp_getmpu(mpu), &pict); | 
 |  | SetControlData(disp, kControlNoPart, kControlPictureHandleTag, sizeof(PicHandle), &pict); | 
 | } | } | 
 |  |  | 
 | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | 
| Line 35  static pascal OSStatus cfWinproc(EventHa | Line 89  static pascal OSStatus cfWinproc(EventHa | 
 | { | { | 
 | case 'MPDF': | case 'MPDF': | 
 | mpu = 0x82; | mpu = 0x82; | 
 |  | strcpy(mpucfg.mout, ""); | 
 |  | strcpy(mpucfg.min, ""); | 
 |  | strcpy(mpucfg.mdl, "GM"); | 
 |  | strcpy(mpucfg.def, ""); | 
 |  | mpucfg.def_en = 0; | 
 | setMPUs(); | setMPUs(); | 
 | break; | break; | 
 |  |  | 
| Line 46  static pascal OSStatus cfWinproc(EventHa | Line 105  static pascal OSStatus cfWinproc(EventHa | 
 | setjmper(&mpu, getMenuValue, 0x03); | setjmper(&mpu, getMenuValue, 0x03); | 
 | break; | break; | 
 |  |  | 
 |  | case 'mido': | 
 |  | strcpy(mpucfg.mout, midiout_name[getMenuValue]); | 
 |  | break; | 
 |  |  | 
 |  | case 'midi': | 
 |  | strcpy(mpucfg.min, midiout_name[getMenuValue]); | 
 |  | break; | 
 |  |  | 
 |  | case 'midm': | 
 |  | strcpy(mpucfg.mdl, cmmidi_mdlname[getMenuValue]); | 
 |  | break; | 
 |  |  | 
 |  | case 'usem': | 
 |  | mpucfg.def_en = GetControl32BitValue(getControlRefByID(cmd.commandID, 0, midiWin)); | 
 |  | break; | 
 |  |  | 
 |  | case 'opnm': | 
 |  | dialog_fileselect(mpucfg.def, sizeof(mpucfg.def), NULL, OPEN_MIMPI); | 
 |  | setMIMPIFilename(); | 
 |  | break; | 
 |  |  | 
 | case kHICommandOK: | case kHICommandOK: | 
 | update = 0; | update = 0; | 
 | if (np2cfg.mpuopt != mpu) { | if (np2cfg.mpuopt != mpu) { | 
 | np2cfg.mpuopt = mpu; | np2cfg.mpuopt = mpu; | 
 | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | 
 | } | } | 
 |  | if (milstr_extendcmp(np2oscfg.mpu.mout, mpucfg.mout) || | 
 |  | milstr_extendcmp(np2oscfg.mpu.min, mpucfg.min) || | 
 |  | milstr_extendcmp(np2oscfg.mpu.mdl, mpucfg.mdl) || | 
 |  | milstr_extendcmp(np2oscfg.mpu.def, mpucfg.def) || | 
 |  | (np2oscfg.mpu.def_en != mpucfg.def_en)) { | 
 |  | np2oscfg.mpu = mpucfg; | 
 |  | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | 
 |  | } | 
 | sysmng_update(update); | sysmng_update(update); | 
 |  |  | 
 | endLoop(midiWin); | endLoop(midiWin); | 
| Line 67  static pascal OSStatus cfWinproc(EventHa | Line 155  static pascal OSStatus cfWinproc(EventHa | 
 | break; | break; | 
 | } | } | 
 | } | } | 
 |  | else if (GetEventClass(event)==kEventClassWindow && GetEventKind(event)==kEventWindowShowing ) { | 
 |  | //setMPUs(); | 
 |  | //SysBeep(0); | 
 |  | } | 
 |  |  | 
 | (void)myHandler; | (void)myHandler; | 
 | (void)userData; | (void)userData; | 
| Line 75  static pascal OSStatus cfWinproc(EventHa | Line 167  static pascal OSStatus cfWinproc(EventHa | 
 |  |  | 
 | static void initMidiWindow(void) { | static void initMidiWindow(void) { | 
 | mpu = np2cfg.mpuopt; | mpu = np2cfg.mpuopt; | 
 |  | mpucfg = np2oscfg.mpu; | 
 | uncheckAllPopupMenuItems('MPio', 16, midiWin); | uncheckAllPopupMenuItems('MPio', 16, midiWin); | 
 | uncheckAllPopupMenuItems('MPin', 4, midiWin); | uncheckAllPopupMenuItems('MPin', 4, midiWin); | 
 |  | uncheckAllPopupMenuItems('mido', 0, midiWin); | 
 |  | uncheckAllPopupMenuItems('midi', 0, midiWin); | 
 |  | uncheckAllPopupMenuItems('midm', 0, midiWin); | 
 | setMPUs(); | setMPUs(); | 
 | } | } | 
 |  |  | 
| Line 88  static void makeNibWindow (IBNibRef nibR | Line 184  static void makeNibWindow (IBNibRef nibR | 
 | if (err == noErr) { | if (err == noErr) { | 
 |  |  | 
 | initMidiWindow(); | initMidiWindow(); | 
| EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess },}; | EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess }, | 
|  | { kEventClassWindow,  kEventWindowShowing} }; | 
 | InstallWindowEventHandler (midiWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)midiWin, &ref); | InstallWindowEventHandler (midiWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)midiWin, &ref); | 
 | ShowSheetWindow(midiWin, hWndMain); | ShowSheetWindow(midiWin, hWndMain); | 
 |  |  |