| version 1.1, 2003/10/25 21:28:14 | version 1.2, 2003/10/28 16:44:44 | 
| Line 15 | Line 15 | 
 | #include        "sound.h" | #include        "sound.h" | 
 | #include        "fmboard.h" | #include        "fmboard.h" | 
 | #include        "dialogutils.h" | #include        "dialogutils.h" | 
 |  | #include        "hid.h" | 
 |  | #include        "soundopt.h" | 
 |  |  | 
| #define getControlValue(a)              GetControl32BitValue(getControlRefByID(a,0,soundWin)) | #define getControlValue(a,b)            GetControl32BitValue(getControlRefByID(a,b,soundWin)) | 
| #define setControlValue(a,b)    SetControl32BitValue(getControlRefByID(a,0,soundWin),b) | #define setControlValue(a,b,c)          SetControl32BitValue(getControlRefByID(a,b,soundWin),c) | 
 |  |  | 
 | #define kMaxNumTabs 6 | #define kMaxNumTabs 6 | 
 | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | 
 |  |  | 
 |  | static OSStatus setupJoyConfig (OSType type); | 
 |  | static void initJoyPad(void); | 
 |  |  | 
 |  | static IBNibRef         nibRef; | 
 | static WindowRef        soundWin; | static WindowRef        soundWin; | 
| static UInt16 lastPaneSelected = 1;     // static, to keep track of it long term (in a more complex application | static WindowRef        joyWin; | 
|  | static UInt16           lastPaneSelected = 1;   // static, to keep track of it long term (in a more complex application | 
 | // you might store this in a data structure in the window refCon) | // you might store this in a data structure in the window refCon) | 
 |  |  | 
 |  |  | 
 | static void setFieldValue(UInt32 type) { |  | 
 | ControlRef  conRef; |  | 
 | Str255              title; |  | 
 | SInt32              value; |  | 
 |  |  | 
 | value = getControlValue(type); |  | 
 | NumToString(value, title); |  | 
 | conRef = getControlRefByID(type, 1, soundWin); |  | 
 | SetControlData(conRef, kControlNoPart, kControlStaticTextTextTag, *title, title+1); |  | 
 | Draw1Control(conRef); |  | 
 | } |  | 
 |  |  | 
 | static  BYTE                    snd26 = 0; | static  BYTE                    snd26 = 0; | 
 | static  BYTE                    snd86 = 0; | static  BYTE                    snd86 = 0; | 
 | static  BYTE                    spb = 0; | static  BYTE                    spb = 0; | 
 | static  BYTE                    spbvrc = 0; | static  BYTE                    spbvrc = 0; | 
 |  |  | 
 |  | BYTE*   cfg[5] = {&np2cfg.vol_fm, &np2cfg.vol_ssg, &np2cfg.vol_adpcm, &np2cfg.vol_pcm, &np2cfg.vol_rhythm}; | 
 |  |  | 
 | static void set26jmp(BYTE value, BYTE bit) { | static void set26jmp(BYTE value, BYTE bit) { | 
 |  |  | 
 | if ((snd26 ^ value) & bit) { | if ((snd26 ^ value) & bit) { | 
| Line 52  static void set26jmp(BYTE value, BYTE bi | Line 48  static void set26jmp(BYTE value, BYTE bi | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  | static void set26s(BYTE chip, OSType io, OSType inturrupt, OSType rom) { | 
 |  | BYTE para; | 
 |  | static short paranum[4] = {0, 3, 1, 2}; | 
 |  | setControlValue(io, 0, ((chip >> 4) & 1)+1); | 
 |  | setControlValue(inturrupt, 0, paranum[(chip >> 6) & 3]+1); | 
 |  | para = chip & 7; | 
 |  | if (para > 4) { | 
 |  | para = 4; | 
 |  | } | 
 |  | setControlValue(rom, 0, para+1); | 
 |  | Draw1Control(getControlRefByID(io, 0, soundWin)); | 
 |  | Draw1Control(getControlRefByID(inturrupt, 0, soundWin)); | 
 |  | Draw1Control(getControlRefByID(rom, 0, soundWin)); | 
 |  | } | 
 |  |  | 
 |  | static void initMixer(BYTE *data) { | 
 |  | short j; | 
 |  | for (j=0;j<5;j++) { | 
 |  | setControlValue('vMix', j, *(data+j)); | 
 |  | } | 
 |  | } | 
 |  | static void init14(BYTE *data) { | 
 |  | short i; | 
 |  | for (i=0;i<6;i++) { | 
 |  | setControlValue('vMix', i+10, *(data+i)); | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | static void set86s(void) { | 
 |  | setControlValue('86io', 0, ((~snd86) & 1)+1); | 
 |  | static short paranum[4] = {0, 1, 3, 2}; | 
 |  | setControlValue('86in', 0, paranum[(snd86 >> 2) & 3]+1); | 
 |  | setControlValue('86id', 0, (((~snd86) >> 5) & 7)+1); | 
 |  | setControlValue('86in', 1, (snd86 & 0x10)?1:0); | 
 |  | setControlValue('86rm', 1, (snd86 & 0x02)?1:0); | 
 |  | } | 
 |  |  | 
 |  | static void setSPB(void) { | 
 |  | set26s(spb, 'spio', 'spin', 'sprm'); | 
 |  | setControlValue('spvl', 0, (spbvrc & 1)?1:0); | 
 |  | setControlValue('spvr', 0, (spbvrc & 2)?1:0); | 
 |  | } | 
 |  |  | 
 | static void initSoundWindow(void) { | static void initSoundWindow(void) { | 
| setControlValue('vFM ', np2cfg.vol_fm); | BYTE        data[5]; | 
| setFieldValue('vFM '); | short       i; | 
| setControlValue('vPSG', np2cfg.vol_ssg); | for (i=0;i<5;i++) { | 
| setFieldValue('vPSG'); | data[i] = *(cfg[i]); | 
| setControlValue('vADP', np2cfg.vol_adpcm); | } | 
| setFieldValue('vADP'); | initMixer(data); | 
| setControlValue('vPCM', np2cfg.vol_pcm); | init14(np2cfg.vol14); | 
| setFieldValue('vPCM'); |  | 
| setControlValue('vRtm', np2cfg.vol_rhythm); |  | 
| setFieldValue('vRtm'); |  | 
|  |  | 
| setControlValue('vLft', np2cfg.vol14[0]); |  | 
| setFieldValue('vLft'); |  | 
| setControlValue('vRit', np2cfg.vol14[1]); |  | 
| setFieldValue('vRit'); |  | 
| setControlValue('vf2 ', np2cfg.vol14[2]); |  | 
| setFieldValue('vf2 '); |  | 
| setControlValue('vf4 ', np2cfg.vol14[3]); |  | 
| setFieldValue('vf4 '); |  | 
| setControlValue('vf8 ', np2cfg.vol14[4]); |  | 
| setFieldValue('vf8 '); |  | 
| setControlValue('vf16', np2cfg.vol14[5]); |  | 
| setFieldValue('vf16'); |  | 
 |  |  | 
 | snd26 = np2cfg.snd26opt; | snd26 = np2cfg.snd26opt; | 
| { | set26s(snd26, '26io', '26in', '26rm'); | 
| BYTE para; |  | 
| static short paranum[4] = {0, 3, 1, 2}; |  | 
| setControlValue('26io', ((snd26 >> 4) & 1)+1); |  | 
| setControlValue('26in', paranum[(snd26 >> 6) & 3]+1); |  | 
| para = snd26 & 7; |  | 
| if (para > 4) { |  | 
| para = 4; |  | 
| } |  | 
| setControlValue('26rm', para+1); |  | 
| } |  | 
 | snd86 = np2cfg.snd86opt; | snd86 = np2cfg.snd86opt; | 
| { | set86s(); | 
| setControlValue('86io', ((~snd86) & 1)+1); |  | 
| static short paranum[4] = {0, 1, 3, 2}; |  | 
| setControlValue('86in', paranum[(snd86 >> 2) & 3]+1); |  | 
| setControlValue('86id', (((~snd86) >> 5) & 7)+1); |  | 
| SetControl32BitValue(getControlRefByID('86in',1,soundWin),(snd86 & 0x10)?1:0); |  | 
| SetControl32BitValue(getControlRefByID('86rm',1,soundWin),(snd86 & 0x02)?1:0); |  | 
| } |  | 
 | spb = np2cfg.spbopt; | spb = np2cfg.spbopt; | 
 | { |  | 
 | BYTE para; |  | 
 | static short paranum[4] = {0, 3, 1, 2}; |  | 
 | setControlValue('spio', ((spb >> 4) & 1)+1); |  | 
 | setControlValue('spin', paranum[(spb >> 6) & 3]+1); |  | 
 | para = spb & 7; |  | 
 | if (para > 4) { |  | 
 | para = 4; |  | 
 | } |  | 
 | setControlValue('sprm', para+1); |  | 
 |  |  | 
 | spbvrc = np2cfg.spb_vrc;                                                                // ver0.30 |  | 
 | setControlValue('spvl',(spbvrc & 1)?1:0); |  | 
 | setControlValue('spvr',(spbvrc & 2)?1:0); |  | 
 | setControlValue('splv',np2cfg.spb_vrl); |  | 
 | setControlValue('sprv',np2cfg.spb_x); |  | 
 | } |  | 
 | spbvrc = np2cfg.spb_vrc;                                                            // ver0.30 | spbvrc = np2cfg.spb_vrc;                                                            // ver0.30 | 
 |  | setSPB(); | 
 |  | setControlValue('splv', 0, np2cfg.spb_vrl); | 
 |  | setControlValue('sprv', 0, np2cfg.spb_x); | 
 |  |  | 
|  | initJoyPad(); | 
 | } | } | 
 |  |  | 
 |  | static BYTE getsnd26io(void) { | 
 |  | SInt32  work; | 
 |  |  | 
 |  | work = getControlValue('26io', 0); | 
 |  | return((BYTE)((work == 2)?0x10:0x00)); | 
 |  | } | 
 |  |  | 
 |  | static BYTE getsnd26int(void) { | 
 |  | switch (getControlValue('26in', 0)) | 
 |  | { | 
 |  | case 1: | 
 |  | return(0x00); | 
 |  |  | 
 |  | case 2: | 
 |  | return(0x80); | 
 |  |  | 
 |  | case 4: | 
 |  | return(0x40); | 
 |  | } | 
 |  | return(0xc0); | 
 |  | } | 
 |  |  | 
 | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | 
 | OSStatus    err = eventNotHandledErr; | OSStatus    err = eventNotHandledErr; | 
 | HICommand   cmd; | HICommand   cmd; | 
 | SINT32      val; | SINT32      val; | 
 | UInt8   value[6]; |  | 
 | UInt8   b; |  | 
 | UInt8   update; | UInt8   update; | 
 | int             renewal; | int             renewal; | 
 |  | short       i,j; | 
 |  | BYTE        defaultmix[5] = {64, 64, 64, 64, 64}; | 
 |  |  | 
 | if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | 
 | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | 
 | switch (cmd.commandID) | switch (cmd.commandID) | 
 | { | { | 
| case 'vFM ': | case 'vDEF': | 
| case 'vPSG': | initMixer(defaultmix); | 
| case 'vADP': |  | 
| case 'vPCM': |  | 
| case 'vRtm': |  | 
| case 'vLft': |  | 
| case 'vRit': |  | 
| case 'vf2 ': |  | 
| case 'vf4 ': |  | 
| case 'vf8 ': |  | 
| case 'vf16': |  | 
| setFieldValue(cmd.commandID); |  | 
 | break; | break; | 
|  |  | 
 | case '26io': | case '26io': | 
| set26jmp(getControlValue('26io'), 0x10); | set26jmp(getsnd26io(), 0x10); | 
|  | break; | 
|  |  | 
|  | case '26in': | 
|  | set26jmp(getsnd26int(), 0xc0); | 
|  | break; | 
|  |  | 
|  | case '26rm': | 
|  | set26jmp(getControlValue('26rm', 0)-1, 0x07); | 
|  | break; | 
|  |  | 
|  | case '26DF': | 
|  | snd26 = 0xd1; | 
|  | set26s(snd26, '26io', '26in', '26rm'); | 
|  | break; | 
|  |  | 
|  | case '86DF': | 
|  | snd86 = 0x7f; | 
|  | set86s(); | 
|  | break; | 
|  |  | 
|  | case 'spDF': | 
|  | spb = 0xd1; | 
|  | spbvrc = 0; | 
|  | setSPB(); | 
 | break; | break; | 
 |  |  | 
 | case kHICommandOK: | case kHICommandOK: | 
 | renewal = 0; | renewal = 0; | 
| val = getControlValue('vFM '); |  | 
| if (val != np2cfg.vol_fm) { | for (j=0;j<5;j++) { | 
| np2cfg.vol_fm = val; | val = getControlValue('vMix', j); | 
| renewal = 1; | if (val != *cfg[j]) { | 
| } | *cfg[j] = val; | 
| val = getControlValue('vPSG'); | renewal = 1; | 
| if (val != np2cfg.vol_ssg) { | } | 
| np2cfg.vol_ssg = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vADP'); |  | 
| if (val != np2cfg.vol_adpcm) { |  | 
| np2cfg.vol_adpcm = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vPCM'); |  | 
| if (val != np2cfg.vol_pcm) { |  | 
| np2cfg.vol_pcm = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vRtm'); |  | 
| if (val != np2cfg.vol_rhythm) { |  | 
| np2cfg.vol_rhythm = val; |  | 
| renewal = 1; |  | 
 | } | } | 
 | if (renewal) { | if (renewal) { | 
 | sysmng_update(SYS_UPDATECFG); | sysmng_update(SYS_UPDATECFG); | 
| Line 193  static pascal OSStatus cfWinproc(EventHa | Line 205  static pascal OSStatus cfWinproc(EventHa | 
 | pcm86gen_update(); | pcm86gen_update(); | 
 |  |  | 
 | renewal = 0; | renewal = 0; | 
| val = getControlValue('vLft'); | for (i=0;i<6;i++) { | 
| if (val != np2cfg.vol14[0]) { | val = getControlValue('vMix',i+10); | 
| np2cfg.vol14[0] = val; | if (val != np2cfg.vol14[i]) { | 
| renewal = 1; | np2cfg.vol14[i] = val; | 
| } | renewal = 1; | 
| val = getControlValue('vRit'); | } | 
| if (val != np2cfg.vol14[1]) { |  | 
| np2cfg.vol14[1] = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vf2 '); |  | 
| if (val != np2cfg.vol14[2]) { |  | 
| np2cfg.vol14[2] = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vf4 '); |  | 
| if (val != np2cfg.vol14[3]) { |  | 
| np2cfg.vol14[3] = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vf8 '); |  | 
| if (val != np2cfg.vol14[4]) { |  | 
| np2cfg.vol14[4] = val; |  | 
| renewal = 1; |  | 
| } |  | 
| val = getControlValue('vf16'); |  | 
| if (val != np2cfg.vol14[5]) { |  | 
| np2cfg.vol14[5] = val; |  | 
| renewal = 1; |  | 
 | } | } | 
 | if (renewal) { | if (renewal) { | 
 | sysmng_update(SYS_UPDATECFG); | sysmng_update(SYS_UPDATECFG); | 
| Line 246  static pascal OSStatus cfWinproc(EventHa | Line 235  static pascal OSStatus cfWinproc(EventHa | 
 | np2cfg.spb_vrc = spbvrc; | np2cfg.spb_vrc = spbvrc; | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
 | } | } | 
| val = getControlValue('spvl'); | val = getControlValue('spvl', 0); | 
 | if (np2cfg.spb_vrl != val) { | if (np2cfg.spb_vrl != val) { | 
 | np2cfg.spb_vrl = val; | np2cfg.spb_vrl = val; | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
 | } | } | 
 | opngen_setVR(np2cfg.spb_vrc, np2cfg.spb_vrl); | opngen_setVR(np2cfg.spb_vrc, np2cfg.spb_vrl); | 
| val = getControlValue('sprv'); | val = getControlValue('sprv', 0); | 
 | if (np2cfg.spb_x != val) { | if (np2cfg.spb_x != val) { | 
 | np2cfg.spb_x = val; | np2cfg.spb_x = val; | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
 | } | } | 
 | sysmng_update(update); | sysmng_update(update); | 
 |  | changeJoyPadSetup(); | 
 |  |  | 
 | endLoop(soundWin); | endLoop(soundWin); | 
 | err=noErr; | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case kHICommandCancel: | case kHICommandCancel: | 
 |  | revertTemporal(); | 
 | endLoop(soundWin); | endLoop(soundWin); | 
 | err=noErr; | err=noErr; | 
 | break; | break; | 
 |  |  | 
 |  | case JOYPAD_UP: | 
 |  | case JOYPAD_DOWN: | 
 |  | case JOYPAD_LEFT: | 
 |  | case JOYPAD_RIGHT: | 
 |  | case JOYPAD_ABUTTON: | 
 |  | case JOYPAD_BBUTTON: | 
 |  | err=setupJoyConfig(cmd.commandID); | 
 |  | break; | 
 |  |  | 
 |  | default: | 
 |  | break; | 
 | } | } | 
 | } | } | 
 |  |  | 
| Line 275  static pascal OSStatus cfWinproc(EventHa | Line 278  static pascal OSStatus cfWinproc(EventHa | 
 | return err; | return err; | 
 | } | } | 
 |  |  | 
 |  | static pascal OSStatus sliderEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | 
 |  | { | 
 |  | return( changeSlider((ControlRef)inUserData, soundWin, 0) ); | 
 |  | } | 
 |  |  | 
 | static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | 
 | { | { | 
 | WindowRef theWindow = (WindowRef)inUserData;  // get the windowRef, passed around as userData | WindowRef theWindow = (WindowRef)inUserData;  // get the windowRef, passed around as userData | 
| Line 288  static pascal OSStatus PrefsTabEventHand | Line 296  static pascal OSStatus PrefsTabEventHand | 
 |  |  | 
 | static void makeNibWindow (IBNibRef nibRef) { | static void makeNibWindow (IBNibRef nibRef) { | 
 | OSStatus    err; | OSStatus    err; | 
 |  | short               i,j,l; | 
 |  | EventHandlerRef     ref; | 
 |  | ControlRef  targetCon[11]; | 
 |  |  | 
 | err = CreateWindowFromNib(nibRef, CFSTR("SoundDialog"), &soundWin); | err = CreateWindowFromNib(nibRef, CFSTR("SoundDialog"), &soundWin); | 
 | if (err == noErr) { | if (err == noErr) { | 
 |  |  | 
 | initSoundWindow(); | initSoundWindow(); | 
 | SetInitialTabState(soundWin, lastPaneSelected, kMaxNumTabs); | SetInitialTabState(soundWin, lastPaneSelected, kMaxNumTabs); | 
 |  |  | 
 | EventTypeSpec   tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; | EventTypeSpec   tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; | 
 | InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,soundWin),  PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, soundWin, NULL ); | InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,soundWin),  PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, soundWin, NULL ); | 
 |  |  | 
 |  | EventTypeSpec   sliderControlEvents[] ={ | 
 |  | { kEventClassControl, kEventControlDraw }, | 
 |  | { kEventClassControl, kEventControlValueFieldChanged } | 
 |  | }; | 
 |  | for (i=0;i<5;i++) { | 
 |  | targetCon[i] = getControlRefByID('vMix',i,soundWin); | 
 |  | } | 
 |  | for (j=0;j<6;j++) { | 
 |  | targetCon[j+5] = getControlRefByID('vMix',10+j,soundWin); | 
 |  | } | 
 |  | for (l=0;l<11;l++) { | 
 |  | InstallControlEventHandler( targetCon[l],  sliderEventHandlerProc , GetEventTypeCount(sliderControlEvents), sliderControlEvents, (void *)targetCon[l], NULL ); | 
 |  | } | 
 |  |  | 
 | EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess },}; | EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess },}; | 
 | EventHandlerRef ref; |  | 
 | InstallWindowEventHandler (soundWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)soundWin, &ref); | InstallWindowEventHandler (soundWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)soundWin, &ref); | 
 | ShowSheetWindow(soundWin, hWndMain); | ShowSheetWindow(soundWin, hWndMain); | 
 |  |  | 
| Line 307  static void makeNibWindow (IBNibRef nibR | Line 334  static void makeNibWindow (IBNibRef nibR | 
 |  |  | 
 | void initSoundOpt( void ) { | void initSoundOpt( void ) { | 
 | OSStatus    err; | OSStatus    err; | 
 | IBNibRef    nibRef; |  | 
 |  |  | 
 | err = CreateNibReference(CFSTR("np2"), &nibRef); | err = CreateNibReference(CFSTR("np2"), &nibRef); | 
 | if (err ==noErr ) { | if (err ==noErr ) { | 
| Line 319  void initSoundOpt( void ) { | Line 345  void initSoundOpt( void ) { | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  | //--------JoyPad | 
 |  |  | 
 |  | static pascal OSStatus joyWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | 
 |  | OSStatus    err = eventNotHandledErr; | 
 |  | HICommand   cmd; | 
 |  |  | 
 |  | if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | 
 |  | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | 
 |  | switch (cmd.commandID) | 
 |  | { | 
 |  | case 'notJ': | 
 |  | HideSheetWindow(joyWin); | 
 |  | DisposeWindow(joyWin); | 
 |  | err = noErr; | 
 |  | break; | 
 |  | default: | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | return err; | 
 |  | } | 
 |  |  | 
 |  | static void setTitle(OSType type, char* elementName) { | 
 |  | Str255 str; | 
 |  | mkstr255(str, elementName); | 
 |  | SetControlTitle(getControlRefByID(type, 0, soundWin), str); | 
 |  | } | 
 |  |  | 
 |  | static OSStatus setupJoyConfig (OSType type) { | 
 |  | OSStatus    err = noErr; | 
 |  | char elementName[256] = "----"; | 
 |  |  | 
 |  | err = CreateWindowFromNib(nibRef, CFSTR("InputWindow"), &joyWin); | 
 |  | if (err == noErr) { | 
 |  | EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess } }; | 
 |  | EventHandlerRef ref; | 
 |  | InstallWindowEventHandler (joyWin, NewEventHandlerUPP(joyWinproc), 1, list, (void *)joyWin, &ref); | 
 |  | ShowSheetWindow(joyWin, soundWin); | 
 |  |  | 
 |  | if (setJoypad(type, elementName)) { | 
 |  | setTitle(type, elementName); | 
 |  | } | 
 |  |  | 
 |  | HideSheetWindow(joyWin); | 
 |  | DisposeWindow(joyWin); | 
 |  | } | 
 |  | return(err); | 
 |  | } | 
 |  |  | 
 |  | static void setName (OSType type) { | 
 |  | char elementName[256] = "----"; | 
 |  | if (getJoypadName(type, elementName)) { | 
 |  | if (elementName) { | 
 |  | setTitle(type, elementName); | 
 |  | } | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | static void initJoyPad(void) { | 
 |  | setName(JOYPAD_UP); | 
 |  | setName(JOYPAD_DOWN); | 
 |  | setName(JOYPAD_LEFT); | 
 |  | setName(JOYPAD_RIGHT); | 
 |  | setName(JOYPAD_ABUTTON); | 
 |  | setName(JOYPAD_BBUTTON); | 
 |  |  | 
 |  | initTemporal(); | 
 |  | } |