mirror of https://github.com/snes9xgit/snes9x.git
Add a framework target from the existing code, deleting or commenting out code that needs to be removed or updated until it compiles. Nothing works at this stage.
This commit is contained in:
parent
931ba0a601
commit
4bd6f30dc8
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1558799895_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1558799884_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1561939424_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1558799815_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1558208804_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"guid":"39754f5c7639f1405cb8f271288abde4","name":"snes9x","path":"/Users/buckley/Projects/snes9x/macosx/snes9x.xcodeproj/project.xcworkspace","projects":["PROJECT@v8_mod=1561940191_hash=f7b7d36057c831b92014210ca4e1513f"]}
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -44,7 +44,7 @@ static OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, long refC
|
||||||
if (SNES9X_OpenCart(NULL))
|
if (SNES9X_OpenCart(NULL))
|
||||||
{
|
{
|
||||||
SNES9X_Go();
|
SNES9X_Go();
|
||||||
QuitApplicationEventLoop();
|
//QuitApplicationEventLoop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AdjustMenus();
|
AdjustMenus();
|
||||||
|
@ -65,7 +65,7 @@ static OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refC
|
||||||
if (SNES9X_OpenCart(NULL))
|
if (SNES9X_OpenCart(NULL))
|
||||||
{
|
{
|
||||||
SNES9X_Go();
|
SNES9X_Go();
|
||||||
QuitApplicationEventLoop();
|
//QuitApplicationEventLoop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AdjustMenus();
|
AdjustMenus();
|
||||||
|
@ -74,7 +74,7 @@ static OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refC
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SNES9X_Go();
|
SNES9X_Go();
|
||||||
QuitApplicationEventLoop();
|
//QuitApplicationEventLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (noErr);
|
return (noErr);
|
||||||
|
@ -91,70 +91,71 @@ static OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, long refC
|
||||||
return (noErr);
|
return (noErr);
|
||||||
|
|
||||||
SNES9X_Quit();
|
SNES9X_Quit();
|
||||||
QuitApplicationEventLoop();
|
//QuitApplicationEventLoop();
|
||||||
|
|
||||||
return (noErr);
|
return (noErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
static OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
||||||
{
|
{
|
||||||
OSErr err;
|
// OSErr err;
|
||||||
FSRef ref;
|
// FSRef ref;
|
||||||
AEDescList docList;
|
// AEDescList docList;
|
||||||
AEKeyword keywd;
|
// AEKeyword keywd;
|
||||||
DescType rtype;
|
// DescType rtype;
|
||||||
Size acsize;
|
// Size acsize;
|
||||||
long count;
|
// long count;
|
||||||
|
//
|
||||||
if (running)
|
// if (running)
|
||||||
return (noErr);
|
// return (noErr);
|
||||||
|
//
|
||||||
err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &docList);
|
// err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &docList);
|
||||||
if (err)
|
// if (err)
|
||||||
return (noErr);
|
// return (noErr);
|
||||||
|
//
|
||||||
err = AECountItems(&docList, &count);
|
// err = AECountItems(&docList, &count);
|
||||||
if (err || (count != 1))
|
// if (err || (count != 1))
|
||||||
{
|
// {
|
||||||
err = AEDisposeDesc(&docList);
|
// err = AEDisposeDesc(&docList);
|
||||||
return (noErr);
|
// return (noErr);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
err = AEGetNthPtr(&docList, 1, typeFSRef, &keywd, &rtype, &ref, sizeof(FSRef), &acsize);
|
// err = AEGetNthPtr(&docList, 1, typeFSRef, &keywd, &rtype, &ref, sizeof(FSRef), &acsize);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
if (SNES9X_OpenCart(&ref))
|
// if (SNES9X_OpenCart(&ref))
|
||||||
{
|
// {
|
||||||
SNES9X_Go();
|
// SNES9X_Go();
|
||||||
QuitApplicationEventLoop();
|
// //QuitApplicationEventLoop();
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
AdjustMenus();
|
// AdjustMenus();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
err = AEDisposeDesc(&docList);
|
// err = AEDisposeDesc(&docList);
|
||||||
|
//
|
||||||
return (noErr);
|
// return (noErr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitAppleEvents (void)
|
void InitAppleEvents (void)
|
||||||
{
|
{
|
||||||
OSErr err;
|
// OSErr err;
|
||||||
|
//
|
||||||
oappUPP = NewAEEventHandlerUPP(AEoapp);
|
// oappUPP = NewAEEventHandlerUPP(AEoapp);
|
||||||
err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, oappUPP, 0L, false);
|
// err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, oappUPP, 0L, false);
|
||||||
|
//
|
||||||
odocUPP = NewAEEventHandlerUPP(AEodoc);
|
// odocUPP = NewAEEventHandlerUPP(AEodoc);
|
||||||
err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, odocUPP, 0L, false);
|
// err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, odocUPP, 0L, false);
|
||||||
|
//
|
||||||
pdocUPP = NewAEEventHandlerUPP(AEpdoc);
|
// pdocUPP = NewAEEventHandlerUPP(AEpdoc);
|
||||||
err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, pdocUPP, 0L, false);
|
// err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, pdocUPP, 0L, false);
|
||||||
|
//
|
||||||
quitUPP = NewAEEventHandlerUPP(AEquit);
|
// quitUPP = NewAEEventHandlerUPP(AEquit);
|
||||||
err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, quitUPP, 0L, false);
|
// err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, quitUPP, 0L, false);
|
||||||
|
//
|
||||||
rappUPP = NewAEEventHandlerUPP(AErapp);
|
// rappUPP = NewAEEventHandlerUPP(AErapp);
|
||||||
err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, rappUPP, 0L, false);
|
// err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, rappUPP, 0L, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeinitAppleEvents (void)
|
void DeinitAppleEvents (void)
|
|
@ -28,6 +28,5 @@ void DeinitMacSound (void);
|
||||||
void MacStartSound (void);
|
void MacStartSound (void);
|
||||||
void MacStopSound (void);
|
void MacStopSound (void);
|
||||||
void ConfigureSoundEffects (void);
|
void ConfigureSoundEffects (void);
|
||||||
void PlayAlertSound (void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,12 +63,8 @@ static void SetAudioUnitSoundFormat (void);
|
||||||
static void SetAudioUnitVolume (void);
|
static void SetAudioUnitVolume (void);
|
||||||
static void StoreBufferFrameSize (void);
|
static void StoreBufferFrameSize (void);
|
||||||
static void ChangeBufferFrameSize (void);
|
static void ChangeBufferFrameSize (void);
|
||||||
static void ReplaceAudioUnitCarbonView (void);
|
|
||||||
static void ResizeSoundEffectsDialog (HIViewRef);
|
|
||||||
static void MacSamplesAvailableCallBack (void *);
|
static void MacSamplesAvailableCallBack (void *);
|
||||||
static OSStatus MacAURenderCallBack (void *, AudioUnitRenderActionFlags *, const AudioTimeStamp *, UInt32, UInt32, AudioBufferList *);
|
static OSStatus MacAURenderCallBack (void *, AudioUnitRenderActionFlags *, const AudioTimeStamp *, UInt32, UInt32, AudioBufferList *);
|
||||||
static OSStatus SoundEffectsEventHandler (EventHandlerCallRef, EventRef, void *);
|
|
||||||
static OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef, EventRef, void *);
|
|
||||||
|
|
||||||
|
|
||||||
void InitMacSound (void)
|
void InitMacSound (void)
|
||||||
|
@ -291,12 +287,7 @@ static void ConnectAudioUnits (void)
|
||||||
callback.inputProc = MacAURenderCallBack;
|
callback.inputProc = MacAURenderCallBack;
|
||||||
callback.inputProcRefCon = NULL;
|
callback.inputProcRefCon = NULL;
|
||||||
|
|
||||||
if (systemVersion >= 0x1050)
|
|
||||||
err = AUGraphSetNodeInputCallback(agraph, aueffect ? cnvNode : outNode, 0, &callback);
|
err = AUGraphSetNodeInputCallback(agraph, aueffect ? cnvNode : outNode, 0, &callback);
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
err = AudioUnitSetProperty(aueffect ? cnvAU : outAU, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((aueffect & kAUReverb) && (aueffect & kAUGraphEQ))
|
if ((aueffect & kAUReverb) && (aueffect & kAUGraphEQ))
|
||||||
{
|
{
|
||||||
|
@ -510,445 +501,157 @@ bool8 S9xOpenSoundDevice (void)
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayAlertSound (void)
|
|
||||||
{
|
|
||||||
if (systemVersion >= 0x1050)
|
|
||||||
AudioServicesPlayAlertSound(kUserPreferredAlert);
|
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
SysBeep(10);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ReplaceAudioUnitCarbonView (void)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
AudioUnit editau;
|
|
||||||
Component cmp;
|
|
||||||
ComponentDescription desc;
|
|
||||||
HIViewRef pane, contentview, ctl;
|
|
||||||
HIViewID cid;
|
|
||||||
Float32Point location, size;
|
|
||||||
Rect rct;
|
|
||||||
UInt32 psize;
|
|
||||||
|
|
||||||
if (carbonView)
|
|
||||||
{
|
|
||||||
err = RemoveEventHandler(carbonViewEventRef);
|
|
||||||
DisposeEventHandlerUPP(carbonViewEventUPP);
|
|
||||||
carbonViewEventRef = NULL;
|
|
||||||
carbonViewEventUPP = NULL;
|
|
||||||
|
|
||||||
CloseComponent(carbonView);
|
|
||||||
carbonView = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cureffect)
|
|
||||||
{
|
|
||||||
case kAUGraphEQ:
|
|
||||||
editau = eqlAU;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kAUReverb:
|
|
||||||
default:
|
|
||||||
editau = revAU;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
desc.componentType = kAudioUnitCarbonViewComponentType;
|
|
||||||
desc.componentSubType = kAUCarbonViewSubType_Generic;
|
|
||||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
|
||||||
desc.componentFlags = 0;
|
|
||||||
desc.componentFlagsMask = 0;
|
|
||||||
|
|
||||||
err = AudioUnitGetPropertyInfo(editau, kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, &psize, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
ComponentDescription *editors;
|
|
||||||
int nEditors;
|
|
||||||
|
|
||||||
nEditors = psize / sizeof(ComponentDescription);
|
|
||||||
|
|
||||||
editors = new ComponentDescription[nEditors];
|
|
||||||
|
|
||||||
err = AudioUnitGetProperty(editau, kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, editors, &psize);
|
|
||||||
if (err == noErr)
|
|
||||||
desc = editors[0];
|
|
||||||
|
|
||||||
delete [] editors;
|
|
||||||
}
|
|
||||||
|
|
||||||
HIViewFindByID(HIViewGetRoot(effectWRef), kHIViewWindowContentID, &contentview);
|
|
||||||
|
|
||||||
cmp = FindNextComponent(NULL, &desc);
|
|
||||||
if (cmp)
|
|
||||||
{
|
|
||||||
err = OpenAComponent(cmp, &carbonView);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
EventTypeSpec event[] = { { kEventClassControl, kEventControlBoundsChanged } };
|
|
||||||
|
|
||||||
GetWindowBounds(effectWRef, kWindowContentRgn, &rct);
|
|
||||||
location.x = 20;
|
|
||||||
location.y = 96;
|
|
||||||
size.x = rct.right - rct.left;
|
|
||||||
size.y = rct.bottom - rct.top;
|
|
||||||
|
|
||||||
err = AudioUnitCarbonViewCreate(carbonView, editau, effectWRef, contentview, &location, &size, &pane);
|
|
||||||
|
|
||||||
carbonViewEventUPP = NewEventHandlerUPP(SoundEffectsCarbonViewEventHandler);
|
|
||||||
err = InstallControlEventHandler(pane, carbonViewEventUPP, GetEventTypeCount(event), event, (void *) effectWRef, &carbonViewEventRef);
|
|
||||||
|
|
||||||
ResizeSoundEffectsDialog(pane);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
carbonView = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
carbonView = NULL;
|
|
||||||
|
|
||||||
cid.id = 0;
|
|
||||||
cid.signature = 'Enab';
|
|
||||||
HIViewFindByID(contentview, cid, &ctl);
|
|
||||||
SetControl32BitValue(ctl, (aueffect & cureffect) ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ResizeSoundEffectsDialog (HIViewRef view)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
HIViewRef ctl, root;
|
|
||||||
HIViewID cid;
|
|
||||||
HIRect bounds;
|
|
||||||
Rect rv;
|
|
||||||
int w, h;
|
|
||||||
|
|
||||||
root = HIViewGetRoot(effectWRef);
|
|
||||||
|
|
||||||
cid.id = 0;
|
|
||||||
cid.signature = 'Enab';
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
|
|
||||||
err = HIViewSetVisible(ctl, false);
|
|
||||||
err = HIViewSetVisible(view, false);
|
|
||||||
|
|
||||||
HIViewGetBounds(view, &bounds);
|
|
||||||
w = ((int) bounds.size.width + 30 > (int) effectWSize.width) ? ((int) bounds.size.width + 30) : (int) effectWSize.width;
|
|
||||||
h = (int) bounds.size.height + 122;
|
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
if (systemVersion < 0x1040)
|
|
||||||
h += 16;
|
|
||||||
#endif
|
|
||||||
GetWindowBounds(effectWRef, kWindowStructureRgn, &rv);
|
|
||||||
rv.right = rv.left + w;
|
|
||||||
rv.bottom = rv.top + h;
|
|
||||||
err = TransitionWindow(effectWRef, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &rv);
|
|
||||||
|
|
||||||
err = HIViewSetVisible(ctl, true);
|
|
||||||
err = HIViewSetVisible(view, true);
|
|
||||||
|
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
if (systemVersion < 0x1040)
|
|
||||||
{
|
|
||||||
HIRect frame;
|
|
||||||
Rect rct;
|
|
||||||
|
|
||||||
GetWindowBounds(effectWRef, kWindowContentRgn, &rv);
|
|
||||||
|
|
||||||
cid.signature = 'SfUI';
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
HIViewGetFrame(ctl, &frame);
|
|
||||||
frame.size.width = (float) (rv.right - rv.left);
|
|
||||||
HIViewSetFrame(ctl, &frame);
|
|
||||||
|
|
||||||
cid.signature = 'LINE';
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
HIViewGetFrame(ctl, &frame);
|
|
||||||
frame.size.width = (float) (rv.right - rv.left - 24);
|
|
||||||
HIViewSetFrame(ctl, &frame);
|
|
||||||
|
|
||||||
rct.top = 0;
|
|
||||||
rct.left = 0;
|
|
||||||
rct.bottom = rv.bottom - rv.top;
|
|
||||||
rct.right = rv.right - rv.left;
|
|
||||||
err = InvalWindowRect(effectWRef, &rct);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureSoundEffects (void)
|
void ConfigureSoundEffects (void)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
IBNibRef nibRef;
|
// IBNibRef nibRef;
|
||||||
|
//
|
||||||
err = CreateNibReference(kMacS9XCFString, &nibRef);
|
// err = CreateNibReference(kMacS9XCFString, &nibRef);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
WindowRef uiparts;
|
// WindowRef uiparts;
|
||||||
|
//
|
||||||
err = CreateWindowFromNib(nibRef, CFSTR("SoundEffect"), &uiparts);
|
// err = CreateWindowFromNib(nibRef, CFSTR("SoundEffect"), &uiparts);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
EventHandlerUPP eventUPP;
|
// EventHandlerUPP eventUPP;
|
||||||
EventHandlerRef eventHandler;
|
// EventHandlerRef eventHandler;
|
||||||
EventTypeSpec event[] = { { kEventClassWindow, kEventWindowClose },
|
// EventTypeSpec event[] = { { kEventClassWindow, kEventWindowClose },
|
||||||
{ kEventClassCommand, kEventCommandProcess },
|
// { kEventClassCommand, kEventCommandProcess },
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } };
|
// { kEventClassCommand, kEventCommandUpdateStatus } };
|
||||||
HIViewRef ctl, userpane, contentview;
|
// HIViewRef ctl, userpane, contentview;
|
||||||
HIViewID cid;
|
// HIViewID cid;
|
||||||
CFStringRef str;
|
// CFStringRef str;
|
||||||
Rect rct;
|
// Rect rct;
|
||||||
WindowAttributes metal = 0;
|
// WindowAttributes metal = 0;
|
||||||
|
//
|
||||||
cid.id = 0;
|
// cid.id = 0;
|
||||||
cid.signature = 'SfUI';
|
// cid.signature = 'SfUI';
|
||||||
HIViewFindByID(HIViewGetRoot(uiparts), cid, &userpane);
|
// HIViewFindByID(HIViewGetRoot(uiparts), cid, &userpane);
|
||||||
GetWindowBounds(uiparts, kWindowContentRgn, &rct);
|
// GetWindowBounds(uiparts, kWindowContentRgn, &rct);
|
||||||
|
//
|
||||||
if (systemVersion >= 0x1040) // AUs support compositing
|
// if (systemVersion >= 0x1040) // AUs support compositing
|
||||||
{
|
// {
|
||||||
HIRect frame;
|
// HIRect frame;
|
||||||
|
//
|
||||||
str = CFCopyLocalizedString(CFSTR("CreateMetalDlg"), "NO");
|
// str = CFCopyLocalizedString(CFSTR("CreateMetalDlg"), "NO");
|
||||||
if (str)
|
// if (str)
|
||||||
{
|
// {
|
||||||
if (CFStringCompare(str, CFSTR("YES"), 0) == kCFCompareEqualTo)
|
// if (CFStringCompare(str, CFSTR("YES"), 0) == kCFCompareEqualTo)
|
||||||
metal = kWindowMetalAttribute;
|
// metal = kWindowMetalAttribute;
|
||||||
|
//
|
||||||
CFRelease(str);
|
// CFRelease(str);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
frame = CGRectMake(0.0f, 0.0f, (float) (rct.right - rct.left), (float) (rct.bottom - rct.top));
|
// frame = CGRectMake(0.0f, 0.0f, (float) (rct.right - rct.left), (float) (rct.bottom - rct.top));
|
||||||
err = CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute | kWindowCompositingAttribute | metal, &rct, &effectWRef);
|
// err = CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute | kWindowCompositingAttribute | metal, &rct, &effectWRef);
|
||||||
err = HIViewFindByID(HIViewGetRoot(effectWRef), kHIViewWindowContentID, &contentview);
|
// err = HIViewFindByID(HIViewGetRoot(effectWRef), kHIViewWindowContentID, &contentview);
|
||||||
err = HIViewAddSubview(contentview, userpane);
|
// err = HIViewAddSubview(contentview, userpane);
|
||||||
err = HIViewSetFrame(userpane, &frame);
|
// err = HIViewSetFrame(userpane, &frame);
|
||||||
}
|
// }
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
// #ifdef MAC_PANTHER_SUPPORT
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
err = CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute, &rct, &effectWRef);
|
// err = CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute, &rct, &effectWRef);
|
||||||
err = CreateRootControl(effectWRef, &contentview);
|
// err = CreateRootControl(effectWRef, &contentview);
|
||||||
err = EmbedControl(userpane, contentview);
|
// err = EmbedControl(userpane, contentview);
|
||||||
MoveControl(userpane, 0, 0);
|
// MoveControl(userpane, 0, 0);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
//
|
||||||
CFRelease(uiparts);
|
// CFRelease(uiparts);
|
||||||
|
//
|
||||||
if (!metal)
|
// if (!metal)
|
||||||
err = SetThemeWindowBackground(effectWRef, kThemeBrushDialogBackgroundActive, false);
|
// err = SetThemeWindowBackground(effectWRef, kThemeBrushDialogBackgroundActive, false);
|
||||||
|
//
|
||||||
str = CFCopyLocalizedString(CFSTR("SoundEffectDlg"), "SoundEffect");
|
// str = CFCopyLocalizedString(CFSTR("SoundEffectDlg"), "SoundEffect");
|
||||||
if (str)
|
// if (str)
|
||||||
{
|
// {
|
||||||
err = SetWindowTitleWithCFString(effectWRef, str);
|
// err = SetWindowTitleWithCFString(effectWRef, str);
|
||||||
CFRelease(str);
|
// CFRelease(str);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (systemVersion >= 0x1040) // AUs support compositing
|
// if (systemVersion >= 0x1040) // AUs support compositing
|
||||||
{
|
// {
|
||||||
HILayoutInfo layoutinfo;
|
// HILayoutInfo layoutinfo;
|
||||||
HIViewRef separator;
|
// HIViewRef separator;
|
||||||
|
//
|
||||||
cid.signature = 'LINE';
|
// cid.signature = 'LINE';
|
||||||
err = HIViewFindByID(userpane, cid, &separator);
|
// err = HIViewFindByID(userpane, cid, &separator);
|
||||||
|
//
|
||||||
layoutinfo.version = kHILayoutInfoVersionZero;
|
// layoutinfo.version = kHILayoutInfoVersionZero;
|
||||||
err = HIViewGetLayoutInfo(userpane, &layoutinfo);
|
// err = HIViewGetLayoutInfo(userpane, &layoutinfo);
|
||||||
|
//
|
||||||
layoutinfo.binding.top.toView = contentview;
|
// layoutinfo.binding.top.toView = contentview;
|
||||||
layoutinfo.binding.top.kind = kHILayoutBindNone;
|
// layoutinfo.binding.top.kind = kHILayoutBindNone;
|
||||||
layoutinfo.binding.bottom.toView = contentview;
|
// layoutinfo.binding.bottom.toView = contentview;
|
||||||
layoutinfo.binding.bottom.kind = kHILayoutBindNone;
|
// layoutinfo.binding.bottom.kind = kHILayoutBindNone;
|
||||||
layoutinfo.binding.left.toView = contentview;
|
// layoutinfo.binding.left.toView = contentview;
|
||||||
layoutinfo.binding.left.kind = kHILayoutBindLeft;
|
// layoutinfo.binding.left.kind = kHILayoutBindLeft;
|
||||||
layoutinfo.binding.right.toView = contentview;
|
// layoutinfo.binding.right.toView = contentview;
|
||||||
layoutinfo.binding.right.kind = kHILayoutBindRight;
|
// layoutinfo.binding.right.kind = kHILayoutBindRight;
|
||||||
err = HIViewSetLayoutInfo(userpane, &layoutinfo);
|
// err = HIViewSetLayoutInfo(userpane, &layoutinfo);
|
||||||
|
//
|
||||||
layoutinfo.version = kHILayoutInfoVersionZero;
|
// layoutinfo.version = kHILayoutInfoVersionZero;
|
||||||
err = HIViewGetLayoutInfo(separator, &layoutinfo);
|
// err = HIViewGetLayoutInfo(separator, &layoutinfo);
|
||||||
|
//
|
||||||
layoutinfo.binding.top.toView = userpane;
|
// layoutinfo.binding.top.toView = userpane;
|
||||||
layoutinfo.binding.top.kind = kHILayoutBindNone;
|
// layoutinfo.binding.top.kind = kHILayoutBindNone;
|
||||||
layoutinfo.binding.bottom.toView = userpane;
|
// layoutinfo.binding.bottom.toView = userpane;
|
||||||
layoutinfo.binding.bottom.kind = kHILayoutBindNone;
|
// layoutinfo.binding.bottom.kind = kHILayoutBindNone;
|
||||||
layoutinfo.binding.left.toView = userpane;
|
// layoutinfo.binding.left.toView = userpane;
|
||||||
layoutinfo.binding.left.kind = kHILayoutBindLeft;
|
// layoutinfo.binding.left.kind = kHILayoutBindLeft;
|
||||||
layoutinfo.binding.right.toView = userpane;
|
// layoutinfo.binding.right.toView = userpane;
|
||||||
layoutinfo.binding.right.kind = kHILayoutBindRight;
|
// layoutinfo.binding.right.kind = kHILayoutBindRight;
|
||||||
err = HIViewSetLayoutInfo(separator, &layoutinfo);
|
// err = HIViewSetLayoutInfo(separator, &layoutinfo);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
eventUPP = NewEventHandlerUPP(SoundEffectsEventHandler);
|
// eventUPP = NewEventHandlerUPP(SoundEffectsEventHandler);
|
||||||
err = InstallWindowEventHandler(effectWRef, eventUPP, GetEventTypeCount(event), event, (void *) effectWRef, &eventHandler);
|
// err = InstallWindowEventHandler(effectWRef, eventUPP, GetEventTypeCount(event), event, (void *) effectWRef, &eventHandler);
|
||||||
|
//
|
||||||
GetWindowBounds(effectWRef, kWindowContentRgn, &rct);
|
// GetWindowBounds(effectWRef, kWindowContentRgn, &rct);
|
||||||
effectWSize.width = (float) (rct.right - rct.left);
|
// effectWSize.width = (float) (rct.right - rct.left);
|
||||||
effectWSize.height = (float) (rct.bottom - rct.top );
|
// effectWSize.height = (float) (rct.bottom - rct.top );
|
||||||
|
//
|
||||||
carbonView = NULL;
|
// carbonView = NULL;
|
||||||
ReplaceAudioUnitCarbonView();
|
// ReplaceAudioUnitCarbonView();
|
||||||
|
//
|
||||||
cid.signature = 'Epop';
|
// cid.signature = 'Epop';
|
||||||
HIViewFindByID(userpane, cid, &ctl);
|
// HIViewFindByID(userpane, cid, &ctl);
|
||||||
switch (cureffect)
|
// switch (cureffect)
|
||||||
{
|
// {
|
||||||
case kAUReverb:
|
// case kAUReverb:
|
||||||
SetControl32BitValue(ctl, 1);
|
// SetControl32BitValue(ctl, 1);
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kAUGraphEQ:
|
// case kAUGraphEQ:
|
||||||
SetControl32BitValue(ctl, 2);
|
// SetControl32BitValue(ctl, 2);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
MoveWindowPosition(effectWRef, kWindowSoundEffect, false);
|
// MoveWindowPosition(effectWRef, kWindowSoundEffect, false);
|
||||||
ShowWindow(effectWRef);
|
// ShowWindow(effectWRef);
|
||||||
err = RunAppModalLoopForWindow(effectWRef);
|
// err = RunAppModalLoopForWindow(effectWRef);
|
||||||
HideWindow(effectWRef);
|
// HideWindow(effectWRef);
|
||||||
SaveWindowPosition(effectWRef, kWindowSoundEffect);
|
// SaveWindowPosition(effectWRef, kWindowSoundEffect);
|
||||||
|
//
|
||||||
if (carbonView)
|
// if (carbonView)
|
||||||
{
|
// {
|
||||||
err = RemoveEventHandler(carbonViewEventRef);
|
// err = RemoveEventHandler(carbonViewEventRef);
|
||||||
DisposeEventHandlerUPP(carbonViewEventUPP);
|
// DisposeEventHandlerUPP(carbonViewEventUPP);
|
||||||
carbonViewEventRef = NULL;
|
// carbonViewEventRef = NULL;
|
||||||
carbonViewEventUPP = NULL;
|
// carbonViewEventUPP = NULL;
|
||||||
|
//
|
||||||
CloseComponent(carbonView);
|
// CloseComponent(carbonView);
|
||||||
carbonView = NULL;
|
// carbonView = NULL;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
err = RemoveEventHandler(eventHandler);
|
// err = RemoveEventHandler(eventHandler);
|
||||||
DisposeEventHandlerUPP(eventUPP);
|
// DisposeEventHandlerUPP(eventUPP);
|
||||||
|
//
|
||||||
CFRelease(effectWRef);
|
// CFRelease(effectWRef);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
DisposeNibReference(nibRef);
|
// DisposeNibReference(nibRef);
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
|
||||||
{
|
|
||||||
OSStatus err, result = eventNotHandledErr;
|
|
||||||
HIViewRef ctl;
|
|
||||||
HIRect bounds;
|
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
|
||||||
{
|
|
||||||
case kEventClassControl:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
case kEventControlBoundsChanged:
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamCurrentBounds, typeHIRect, NULL, sizeof(HIRect), NULL, &bounds);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
if ((bounds.size.width > 0) && (bounds.size.height > 0))
|
|
||||||
ResizeSoundEffectsDialog(ctl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus SoundEffectsEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
|
||||||
{
|
|
||||||
OSStatus err, result = eventNotHandledErr;
|
|
||||||
WindowRef tWindowRef = (WindowRef) inUserData;
|
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
|
||||||
{
|
|
||||||
case kEventClassWindow:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
case kEventWindowClose:
|
|
||||||
QuitAppModalLoopForWindow(tWindowRef);
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEventClassCommand:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
HICommand tHICommand;
|
|
||||||
|
|
||||||
case kEventCommandUpdateStatus:
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr && tHICommand.commandID == 'clos')
|
|
||||||
{
|
|
||||||
UpdateMenuCommandStatus(true);
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEventCommandProcess:
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
switch (tHICommand.commandID)
|
|
||||||
{
|
|
||||||
case 'Enab':
|
|
||||||
{
|
|
||||||
Boolean r = false;
|
|
||||||
|
|
||||||
mboxPause = true;
|
|
||||||
|
|
||||||
err = AUGraphIsRunning(agraph, &r);
|
|
||||||
if (err == noErr && r)
|
|
||||||
err = AUGraphStop(agraph);
|
|
||||||
|
|
||||||
DisconnectAudioUnits();
|
|
||||||
err = AUGraphUninitialize(agraph);
|
|
||||||
|
|
||||||
aueffect ^= cureffect;
|
|
||||||
|
|
||||||
SetAudioUnitSoundFormat();
|
|
||||||
ChangeBufferFrameSize();
|
|
||||||
|
|
||||||
err = AUGraphInitialize(agraph);
|
|
||||||
ConnectAudioUnits();
|
|
||||||
|
|
||||||
if (r)
|
|
||||||
err = AUGraphStart(agraph);
|
|
||||||
|
|
||||||
mboxPause = false;
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'Revb':
|
|
||||||
cureffect = kAUReverb;
|
|
||||||
ReplaceAudioUnitCarbonView();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'GrEQ':
|
|
||||||
cureffect = kAUGraphEQ;
|
|
||||||
ReplaceAudioUnitCarbonView();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,14 @@
|
||||||
#ifndef _mac_cart_h_
|
#ifndef _mac_cart_h_
|
||||||
#define _mac_cart_h_
|
#define _mac_cart_h_
|
||||||
|
|
||||||
bool8 NavOpenROMImage (FSRef *);
|
#import <Cocoa/Cocoa.h>
|
||||||
bool8 NavBeginOpenROMImageSheet (WindowRef, CFStringRef);
|
|
||||||
bool8 NavEndOpenROMImageSheet (FSRef *);
|
NSURL *NavOpenROMImage ();
|
||||||
bool8 NavBeginChooseFolderSheet (WindowRef);
|
NSURL *NavChooseFolderSheet (NSWindow *);
|
||||||
bool8 NavEndChooseFolderSheet (FSRef *);
|
NSURL *NavFreezeTo ();
|
||||||
bool8 NavFreezeTo (char *);
|
NSURL *NavDefrostFrom ();
|
||||||
bool8 NavDefrostFrom (char *);
|
NSURL *NavRecordMovieTo ();
|
||||||
bool8 NavRecordMovieTo (char *);
|
NSURL *NavPlayMovieFrom ();
|
||||||
bool8 NavPlayMovieFrom (char *);
|
NSURL *NavQTMovieRecordTo ();
|
||||||
bool8 NavQTMovieRecordTo (char *);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
2807
macosx/mac-cart.mm
2807
macosx/mac-cart.mm
File diff suppressed because it is too large
Load Diff
|
@ -1,594 +0,0 @@
|
||||||
/*****************************************************************************\
|
|
||||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
||||||
This file is licensed under the Snes9x License.
|
|
||||||
For further information, consult the LICENSE file in the root directory.
|
|
||||||
\*****************************************************************************/
|
|
||||||
|
|
||||||
/***********************************************************************************
|
|
||||||
SNES9X for Mac OS (c) Copyright John Stiles
|
|
||||||
|
|
||||||
Snes9x for Mac OS X
|
|
||||||
|
|
||||||
(c) Copyright 2001 - 2011 zones
|
|
||||||
(c) Copyright 2002 - 2005 107
|
|
||||||
(c) Copyright 2002 PB1400c
|
|
||||||
(c) Copyright 2004 Alexander and Sander
|
|
||||||
(c) Copyright 2004 - 2005 Steven Seeger
|
|
||||||
(c) Copyright 2005 Ryan Vogt
|
|
||||||
***********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "port.h"
|
|
||||||
#include "cheats.h"
|
|
||||||
|
|
||||||
#define __STDC_FORMAT_MACROS
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#include "mac-prefix.h"
|
|
||||||
#include "mac-dialog.h"
|
|
||||||
#include "mac-os.h"
|
|
||||||
#include "mac-stringtools.h"
|
|
||||||
#include "mac-cheat.h"
|
|
||||||
|
|
||||||
#define kDataBrowser 'BRSR'
|
|
||||||
#define kCmCheckBox 'CHK_'
|
|
||||||
#define kCmAddress 'ADDR'
|
|
||||||
#define kCmValue 'VALU'
|
|
||||||
#define kCmDescription 'DESC'
|
|
||||||
#define kNewButton 'NEW_'
|
|
||||||
#define kDelButton 'DEL_'
|
|
||||||
#define kAllButton 'ALL_'
|
|
||||||
|
|
||||||
extern SCheatData Cheat;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32 id;
|
|
||||||
uint32 address;
|
|
||||||
uint8 value;
|
|
||||||
bool8 valid;
|
|
||||||
bool8 enabled;
|
|
||||||
char description[22];
|
|
||||||
} CheatItem;
|
|
||||||
|
|
||||||
static WindowRef wRef;
|
|
||||||
static HIViewRef dbRef;
|
|
||||||
static CheatItem citem[MAC_MAX_CHEATS];
|
|
||||||
static uint32 numofcheats;
|
|
||||||
|
|
||||||
static void InitCheatItems (void);
|
|
||||||
static void ImportCheatItems (void);
|
|
||||||
static void DetachCheatItems (void);
|
|
||||||
static void AddCheatItem (void);
|
|
||||||
static void DeleteCheatItem (void);
|
|
||||||
static void EnableAllCheatItems (void);
|
|
||||||
static void DBItemNotificationCallBack (HIViewRef, DataBrowserItemID, DataBrowserItemNotification);
|
|
||||||
static Boolean DBCompareCallBack (HIViewRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID);
|
|
||||||
static OSStatus DBClientDataCallback (HIViewRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean);
|
|
||||||
static OSStatus CheatEventHandler (EventHandlerCallRef, EventRef, void *);
|
|
||||||
|
|
||||||
|
|
||||||
static void InitCheatItems (void)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
|
||||||
{
|
|
||||||
citem[i].id = i + 1;
|
|
||||||
citem[i].valid = false;
|
|
||||||
citem[i].enabled = false;
|
|
||||||
citem[i].address = 0;
|
|
||||||
citem[i].value = 0;
|
|
||||||
sprintf(citem[i].description, "Cheat %03" PRIu32, citem[i].id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImportCheatItems (void)
|
|
||||||
{
|
|
||||||
int cheat_num = std::min((int)Cheat.g.size(), MAC_MAX_CHEATS);
|
|
||||||
for (unsigned int i = 0; i < cheat_num; i++)
|
|
||||||
{
|
|
||||||
citem[i].valid = true;
|
|
||||||
citem[i].enabled = Cheat.g[i].enabled;
|
|
||||||
citem[i].address = Cheat.g[i].c[0].address; // mac dialog only supports one cheat per group at the moment
|
|
||||||
citem[i].value = Cheat.g[i].c[0].byte;
|
|
||||||
strncpy(citem[i].description, Cheat.g[i].name, 21);
|
|
||||||
citem[i].description[21] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DetachCheatItems (void)
|
|
||||||
{
|
|
||||||
S9xDeleteCheats();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
|
||||||
{
|
|
||||||
if (citem[i].valid)
|
|
||||||
{
|
|
||||||
char code[10];
|
|
||||||
snprintf(code, 10, "%x=%x", citem[i].address, citem[i].value);
|
|
||||||
int index = S9xAddCheatGroup(citem[i].description, code);
|
|
||||||
if(citem[i].enabled && index >= 0)
|
|
||||||
S9xEnableCheatGroup(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureCheat (void)
|
|
||||||
{
|
|
||||||
if (!cartOpen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OSStatus err;
|
|
||||||
IBNibRef nibRef;
|
|
||||||
|
|
||||||
err = CreateNibReference(kMacS9XCFString, &nibRef);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = CreateWindowFromNib(nibRef, CFSTR("CheatEntry"), &wRef);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
DataBrowserCallbacks callbacks;
|
|
||||||
EventHandlerRef eref;
|
|
||||||
EventHandlerUPP eUPP;
|
|
||||||
EventTypeSpec events[] = { { kEventClassCommand, kEventCommandProcess },
|
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus },
|
|
||||||
{ kEventClassWindow, kEventWindowClose } };
|
|
||||||
HIViewRef ctl, root;
|
|
||||||
HIViewID cid;
|
|
||||||
|
|
||||||
root = HIViewGetRoot(wRef);
|
|
||||||
cid.id = 0;
|
|
||||||
cid.signature = kDataBrowser;
|
|
||||||
HIViewFindByID(root, cid, &dbRef);
|
|
||||||
|
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
if (systemVersion < 0x1040)
|
|
||||||
{
|
|
||||||
HISize minSize;
|
|
||||||
Rect rct;
|
|
||||||
|
|
||||||
GetWindowBounds(wRef, kWindowContentRgn, &rct);
|
|
||||||
minSize.width = (float) (rct.right - rct.left);
|
|
||||||
minSize.height = (float) (rct.bottom - rct.top );
|
|
||||||
err = SetWindowResizeLimits(wRef, &minSize, NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
callbacks.version = kDataBrowserLatestCallbacks;
|
|
||||||
err = InitDataBrowserCallbacks(&callbacks);
|
|
||||||
callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DBClientDataCallback);
|
|
||||||
callbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(DBCompareCallBack);
|
|
||||||
callbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DBItemNotificationCallBack);
|
|
||||||
err = SetDataBrowserCallbacks(dbRef, &callbacks);
|
|
||||||
|
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
err = DataBrowserChangeAttributes(dbRef, kDataBrowserAttributeListViewAlternatingRowColors, kDataBrowserAttributeNone);
|
|
||||||
|
|
||||||
InitCheatItems();
|
|
||||||
ImportCheatItems();
|
|
||||||
|
|
||||||
DataBrowserItemID *id;
|
|
||||||
|
|
||||||
id = new DataBrowserItemID[MAC_MAX_CHEATS];
|
|
||||||
if (!id)
|
|
||||||
QuitWithFatalError(0, "cheat 01");
|
|
||||||
|
|
||||||
numofcheats = 0;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
|
||||||
{
|
|
||||||
if (citem[i].valid)
|
|
||||||
{
|
|
||||||
id[numofcheats] = citem[i].id;
|
|
||||||
numofcheats++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numofcheats)
|
|
||||||
err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, numofcheats, id, kDataBrowserItemNoProperty);
|
|
||||||
|
|
||||||
delete [] id;
|
|
||||||
|
|
||||||
cid.signature = kNewButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
if (numofcheats == MAC_MAX_CHEATS)
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
else
|
|
||||||
err = ActivateControl(ctl);
|
|
||||||
|
|
||||||
cid.signature = kAllButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
if (numofcheats == 0)
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
else
|
|
||||||
err = ActivateControl(ctl);
|
|
||||||
|
|
||||||
cid.signature = kDelButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
|
|
||||||
eUPP = NewEventHandlerUPP(CheatEventHandler);
|
|
||||||
err = InstallWindowEventHandler(wRef, eUPP, GetEventTypeCount(events), events, (void *) wRef, &eref);
|
|
||||||
|
|
||||||
err = SetKeyboardFocus(wRef, dbRef, kControlFocusNextPart);
|
|
||||||
|
|
||||||
MoveWindowPosition(wRef, kWindowCheatEntry, true);
|
|
||||||
ShowWindow(wRef);
|
|
||||||
err = RunAppModalLoopForWindow(wRef);
|
|
||||||
HideWindow(wRef);
|
|
||||||
SaveWindowPosition(wRef, kWindowCheatEntry);
|
|
||||||
|
|
||||||
err = RemoveEventHandler(eref);
|
|
||||||
DisposeEventHandlerUPP(eUPP);
|
|
||||||
|
|
||||||
DisposeDataBrowserItemNotificationUPP(callbacks.u.v1.itemNotificationCallback);
|
|
||||||
DisposeDataBrowserItemCompareUPP(callbacks.u.v1.itemCompareCallback);
|
|
||||||
DisposeDataBrowserItemDataUPP(callbacks.u.v1.itemDataCallback);
|
|
||||||
|
|
||||||
CFRelease(wRef);
|
|
||||||
|
|
||||||
DetachCheatItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
DisposeNibReference(nibRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddCheatItem (void)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
HIViewRef ctl, root;
|
|
||||||
HIViewID cid;
|
|
||||||
DataBrowserItemID id[1];
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (numofcheats == MAC_MAX_CHEATS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < MAC_MAX_CHEATS; i++)
|
|
||||||
if (citem[i].valid == false)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == MAC_MAX_CHEATS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
numofcheats++;
|
|
||||||
citem[i].valid = true;
|
|
||||||
citem[i].enabled = false;
|
|
||||||
citem[i].address = 0;
|
|
||||||
citem[i].value = 0;
|
|
||||||
sprintf(citem[i].description, "Cheat %03" PRIu32, citem[i].id);
|
|
||||||
|
|
||||||
id[0] = citem[i].id;
|
|
||||||
err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, 1, id, kDataBrowserItemNoProperty);
|
|
||||||
err = RevealDataBrowserItem(dbRef, id[0], kCmAddress, true);
|
|
||||||
|
|
||||||
root = HIViewGetRoot(wRef);
|
|
||||||
cid.id = 0;
|
|
||||||
|
|
||||||
if (numofcheats == MAC_MAX_CHEATS)
|
|
||||||
{
|
|
||||||
cid.signature = kNewButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numofcheats)
|
|
||||||
{
|
|
||||||
cid.signature = kAllButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
err = ActivateControl(ctl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DeleteCheatItem (void)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
HIViewRef ctl, root;
|
|
||||||
HIViewID cid;
|
|
||||||
Handle selectedItems;
|
|
||||||
ItemCount selectionCount;
|
|
||||||
|
|
||||||
selectedItems = NewHandle(0);
|
|
||||||
if (!selectedItems)
|
|
||||||
return;
|
|
||||||
|
|
||||||
err = GetDataBrowserItems(dbRef, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, selectedItems);
|
|
||||||
selectionCount = (GetHandleSize(selectedItems) / sizeof(DataBrowserItemID));
|
|
||||||
|
|
||||||
if (selectionCount == 0)
|
|
||||||
{
|
|
||||||
DisposeHandle(selectedItems);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = RemoveDataBrowserItems(dbRef, kDataBrowserNoItem, selectionCount, (DataBrowserItemID *) *selectedItems, kDataBrowserItemNoProperty);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < selectionCount; i++)
|
|
||||||
{
|
|
||||||
citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].valid = false;
|
|
||||||
citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].enabled = false;
|
|
||||||
numofcheats--;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisposeHandle(selectedItems);
|
|
||||||
|
|
||||||
root = HIViewGetRoot(wRef);
|
|
||||||
cid.id = 0;
|
|
||||||
|
|
||||||
if (numofcheats < MAC_MAX_CHEATS)
|
|
||||||
{
|
|
||||||
cid.signature = kNewButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
err = ActivateControl(ctl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numofcheats == 0)
|
|
||||||
{
|
|
||||||
cid.signature = kAllButton;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void EnableAllCheatItems (void)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
|
||||||
if (citem[i].valid)
|
|
||||||
citem[i].enabled = true;
|
|
||||||
|
|
||||||
err = UpdateDataBrowserItems(dbRef, kDataBrowserNoItem, kDataBrowserNoItem, NULL, kDataBrowserItemNoProperty, kCmCheckBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus DBClientDataCallback (HIViewRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue)
|
|
||||||
{
|
|
||||||
OSStatus err, result;
|
|
||||||
CFStringRef str;
|
|
||||||
Boolean r;
|
|
||||||
uint32 address;
|
|
||||||
uint8 value;
|
|
||||||
char code[256];
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
|
|
||||||
switch (property)
|
|
||||||
{
|
|
||||||
case kCmCheckBox:
|
|
||||||
ThemeButtonValue buttonValue;
|
|
||||||
|
|
||||||
if (changeValue)
|
|
||||||
{
|
|
||||||
err = GetDataBrowserItemDataButtonValue(itemData, &buttonValue);
|
|
||||||
citem[itemID - 1].enabled = (buttonValue == kThemeButtonOn) ? true : false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
err = SetDataBrowserItemDataButtonValue(itemData, citem[itemID - 1].enabled ? kThemeButtonOn : kThemeButtonOff);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmAddress:
|
|
||||||
if (changeValue)
|
|
||||||
{
|
|
||||||
err = GetDataBrowserItemDataText(itemData, &str);
|
|
||||||
r = CFStringGetCString(str, code, 256, CFStringGetSystemEncoding());
|
|
||||||
CFRelease(str);
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
Boolean translated;
|
|
||||||
|
|
||||||
if (S9xProActionReplayToRaw(code, address, value) == NULL)
|
|
||||||
translated = true;
|
|
||||||
else
|
|
||||||
if (S9xGameGenieToRaw(code, address, value) == NULL)
|
|
||||||
translated = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
translated = false;
|
|
||||||
if (sscanf(code, "%" SCNx32, &address) != 1)
|
|
||||||
address = 0;
|
|
||||||
else
|
|
||||||
address &= 0xFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
citem[itemID - 1].address = address;
|
|
||||||
sprintf(code, "%06" PRIX32, address);
|
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
|
||||||
err = SetDataBrowserItemDataText(itemData, str);
|
|
||||||
CFRelease(str);
|
|
||||||
|
|
||||||
if (translated)
|
|
||||||
{
|
|
||||||
DataBrowserItemID id[1];
|
|
||||||
|
|
||||||
citem[itemID - 1].value = value;
|
|
||||||
id[0] = itemID;
|
|
||||||
err = UpdateDataBrowserItems(browser, kDataBrowserNoItem, 1, id, kDataBrowserItemNoProperty, kCmValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(code, "%06" PRIX32, citem[itemID - 1].address);
|
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
|
||||||
err = SetDataBrowserItemDataText(itemData, str);
|
|
||||||
CFRelease(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmValue:
|
|
||||||
if (changeValue)
|
|
||||||
{
|
|
||||||
err = GetDataBrowserItemDataText(itemData, &str);
|
|
||||||
r = CFStringGetCString(str, code, 256, CFStringGetSystemEncoding());
|
|
||||||
CFRelease(str);
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
uint32 byte;
|
|
||||||
|
|
||||||
if (sscanf(code, "%" SCNx32, &byte) == 1)
|
|
||||||
citem[itemID - 1].value = (uint8) byte;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
citem[itemID - 1].value = 0;
|
|
||||||
err = SetDataBrowserItemDataText(itemData, CFSTR("00"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(code, "%02" PRIX8, citem[itemID - 1].value);
|
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
|
||||||
err = SetDataBrowserItemDataText(itemData, str);
|
|
||||||
CFRelease(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmDescription:
|
|
||||||
if (changeValue)
|
|
||||||
{
|
|
||||||
code[0] = 0;
|
|
||||||
err = GetDataBrowserItemDataText(itemData, &str);
|
|
||||||
strcpy(code, GetMultiByteCharacters(str, 19));
|
|
||||||
CFRelease(str);
|
|
||||||
|
|
||||||
if (code[0] == 0)
|
|
||||||
{
|
|
||||||
code[0] = ' ';
|
|
||||||
code[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(citem[itemID - 1].description, code);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, citem[itemID - 1].description, CFStringGetSystemEncoding());
|
|
||||||
err = SetDataBrowserItemDataText(itemData, str);
|
|
||||||
CFRelease(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kDataBrowserItemIsActiveProperty:
|
|
||||||
err = SetDataBrowserItemDataBooleanValue(itemData, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kDataBrowserItemIsEditableProperty:
|
|
||||||
err = SetDataBrowserItemDataBooleanValue(itemData, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
result = errDataBrowserPropertyNotSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Boolean DBCompareCallBack (HIViewRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty)
|
|
||||||
{
|
|
||||||
Boolean result = false;
|
|
||||||
|
|
||||||
switch (sortProperty)
|
|
||||||
{
|
|
||||||
case kCmCheckBox:
|
|
||||||
result = (citem[itemOne - 1].enabled && !(citem[itemTwo - 1].enabled)) ? true : false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmAddress:
|
|
||||||
result = (citem[itemOne - 1].address < citem[itemTwo - 1].address) ? true : false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmValue:
|
|
||||||
result = (citem[itemOne - 1].value < citem[itemTwo - 1].value) ? true : false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kCmDescription:
|
|
||||||
result = (strcmp(citem[itemOne - 1].description, citem[itemTwo - 1].description) < 0) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DBItemNotificationCallBack (HIViewRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
HIViewRef ctl;
|
|
||||||
HIViewID cid = { kDelButton, 0 };
|
|
||||||
ItemCount selectionCount;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case kDataBrowserSelectionSetChanged:
|
|
||||||
HIViewFindByID(HIViewGetRoot(wRef), cid, &ctl);
|
|
||||||
|
|
||||||
err = GetDataBrowserItemCount(browser, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, &selectionCount);
|
|
||||||
if (selectionCount == 0)
|
|
||||||
err = DeactivateControl(ctl);
|
|
||||||
else
|
|
||||||
err = ActivateControl(ctl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus CheatEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
|
|
||||||
{
|
|
||||||
OSStatus err, result = eventNotHandledErr;
|
|
||||||
WindowRef tWindowRef;
|
|
||||||
|
|
||||||
tWindowRef = (WindowRef) inUserData;
|
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
|
||||||
{
|
|
||||||
case kEventClassWindow:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
case kEventWindowClose:
|
|
||||||
QuitAppModalLoopForWindow(tWindowRef);
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEventClassCommand:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
HICommand tHICommand;
|
|
||||||
|
|
||||||
case kEventCommandUpdateStatus:
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr && tHICommand.commandID == 'clos')
|
|
||||||
{
|
|
||||||
UpdateMenuCommandStatus(true);
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEventCommandProcess:
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
switch (tHICommand.commandID)
|
|
||||||
{
|
|
||||||
case kNewButton:
|
|
||||||
AddCheatItem();
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kDelButton:
|
|
||||||
DeleteCheatItem();
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kAllButton:
|
|
||||||
EnableAllCheatItems();
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
|
@ -0,0 +1,550 @@
|
||||||
|
/*****************************************************************************\
|
||||||
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||||
|
This file is licensed under the Snes9x License.
|
||||||
|
For further information, consult the LICENSE file in the root directory.
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************************
|
||||||
|
SNES9X for Mac OS (c) Copyright John Stiles
|
||||||
|
|
||||||
|
Snes9x for Mac OS X
|
||||||
|
|
||||||
|
(c) Copyright 2001 - 2011 zones
|
||||||
|
(c) Copyright 2002 - 2005 107
|
||||||
|
(c) Copyright 2002 PB1400c
|
||||||
|
(c) Copyright 2004 Alexander and Sander
|
||||||
|
(c) Copyright 2004 - 2005 Steven Seeger
|
||||||
|
(c) Copyright 2005 Ryan Vogt
|
||||||
|
***********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "port.h"
|
||||||
|
#include "cheats.h"
|
||||||
|
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "mac-prefix.h"
|
||||||
|
#include "mac-dialog.h"
|
||||||
|
#include "mac-os.h"
|
||||||
|
#include "mac-stringtools.h"
|
||||||
|
#include "mac-cheat.h"
|
||||||
|
|
||||||
|
#define kDataBrowser 'BRSR'
|
||||||
|
#define kCmCheckBox 'CHK_'
|
||||||
|
#define kCmAddress 'ADDR'
|
||||||
|
#define kCmValue 'VALU'
|
||||||
|
#define kCmDescription 'DESC'
|
||||||
|
#define kNewButton 'NEW_'
|
||||||
|
#define kDelButton 'DEL_'
|
||||||
|
#define kAllButton 'ALL_'
|
||||||
|
|
||||||
|
extern SCheatData Cheat;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32 id;
|
||||||
|
uint32 address;
|
||||||
|
uint8 value;
|
||||||
|
bool8 valid;
|
||||||
|
bool8 enabled;
|
||||||
|
char description[22];
|
||||||
|
} CheatItem;
|
||||||
|
|
||||||
|
static WindowRef wRef;
|
||||||
|
static HIViewRef dbRef;
|
||||||
|
static CheatItem citem[MAC_MAX_CHEATS];
|
||||||
|
static uint32 numofcheats;
|
||||||
|
|
||||||
|
static void InitCheatItems (void);
|
||||||
|
static void ImportCheatItems (void);
|
||||||
|
static void DetachCheatItems (void);
|
||||||
|
static void AddCheatItem (void);
|
||||||
|
static void DeleteCheatItem (void);
|
||||||
|
static void EnableAllCheatItems (void);
|
||||||
|
static void DBItemNotificationCallBack (HIViewRef, DataBrowserItemID, DataBrowserItemNotification);
|
||||||
|
static OSStatus CheatEventHandler (EventHandlerCallRef, EventRef, void *);
|
||||||
|
|
||||||
|
|
||||||
|
static void InitCheatItems (void)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
|
{
|
||||||
|
citem[i].id = i + 1;
|
||||||
|
citem[i].valid = false;
|
||||||
|
citem[i].enabled = false;
|
||||||
|
citem[i].address = 0;
|
||||||
|
citem[i].value = 0;
|
||||||
|
sprintf(citem[i].description, "Cheat %03" PRIu32, citem[i].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImportCheatItems (void)
|
||||||
|
{
|
||||||
|
int cheat_num = std::min((int)Cheat.g.size(), MAC_MAX_CHEATS);
|
||||||
|
for (unsigned int i = 0; i < cheat_num; i++)
|
||||||
|
{
|
||||||
|
citem[i].valid = true;
|
||||||
|
citem[i].enabled = Cheat.g[i].enabled;
|
||||||
|
citem[i].address = Cheat.g[i].c[0].address; // mac dialog only supports one cheat per group at the moment
|
||||||
|
citem[i].value = Cheat.g[i].c[0].byte;
|
||||||
|
strncpy(citem[i].description, Cheat.g[i].name, 21);
|
||||||
|
citem[i].description[21] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DetachCheatItems (void)
|
||||||
|
{
|
||||||
|
S9xDeleteCheats();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
|
{
|
||||||
|
if (citem[i].valid)
|
||||||
|
{
|
||||||
|
char code[10];
|
||||||
|
snprintf(code, 10, "%x=%x", citem[i].address, citem[i].value);
|
||||||
|
int index = S9xAddCheatGroup(citem[i].description, code);
|
||||||
|
if(citem[i].enabled && index >= 0)
|
||||||
|
S9xEnableCheatGroup(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureCheat (void)
|
||||||
|
{
|
||||||
|
if (!cartOpen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// OSStatus err;
|
||||||
|
// IBNibRef nibRef;
|
||||||
|
//
|
||||||
|
// err = CreateNibReference(kMacS9XCFString, &nibRef);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = CreateWindowFromNib(nibRef, CFSTR("CheatEntry"), &wRef);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// DataBrowserCallbacks callbacks;
|
||||||
|
// EventHandlerRef eref;
|
||||||
|
// EventHandlerUPP eUPP;
|
||||||
|
// EventTypeSpec events[] = { { kEventClassCommand, kEventCommandProcess },
|
||||||
|
// { kEventClassCommand, kEventCommandUpdateStatus },
|
||||||
|
// { kEventClassWindow, kEventWindowClose } };
|
||||||
|
// HIViewRef ctl, root;
|
||||||
|
// HIViewID cid;
|
||||||
|
//
|
||||||
|
// root = HIViewGetRoot(wRef);
|
||||||
|
// cid.id = 0;
|
||||||
|
// cid.signature = kDataBrowser;
|
||||||
|
// HIViewFindByID(root, cid, &dbRef);
|
||||||
|
//
|
||||||
|
// #ifdef MAC_PANTHER_SUPPORT
|
||||||
|
// if (systemVersion < 0x1040)
|
||||||
|
// {
|
||||||
|
// HISize minSize;
|
||||||
|
// Rect rct;
|
||||||
|
//
|
||||||
|
// GetWindowBounds(wRef, kWindowContentRgn, &rct);
|
||||||
|
// minSize.width = (float) (rct.right - rct.left);
|
||||||
|
// minSize.height = (float) (rct.bottom - rct.top );
|
||||||
|
// err = SetWindowResizeLimits(wRef, &minSize, NULL);
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
//
|
||||||
|
// callbacks.version = kDataBrowserLatestCallbacks;
|
||||||
|
// err = InitDataBrowserCallbacks(&callbacks);
|
||||||
|
// callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DBClientDataCallback);
|
||||||
|
// callbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(DBCompareCallBack);
|
||||||
|
// callbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DBItemNotificationCallBack);
|
||||||
|
// err = SetDataBrowserCallbacks(dbRef, &callbacks);
|
||||||
|
//
|
||||||
|
// if (systemVersion >= 0x1040)
|
||||||
|
// err = DataBrowserChangeAttributes(dbRef, kDataBrowserAttributeListViewAlternatingRowColors, kDataBrowserAttributeNone);
|
||||||
|
//
|
||||||
|
// InitCheatItems();
|
||||||
|
// ImportCheatItems();
|
||||||
|
//
|
||||||
|
// DataBrowserItemID *id;
|
||||||
|
//
|
||||||
|
// id = new DataBrowserItemID[MAC_MAX_CHEATS];
|
||||||
|
// if (!id)
|
||||||
|
// QuitWithFatalError(@"cheat 01");
|
||||||
|
//
|
||||||
|
// numofcheats = 0;
|
||||||
|
//
|
||||||
|
// for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
|
// {
|
||||||
|
// if (citem[i].valid)
|
||||||
|
// {
|
||||||
|
// id[numofcheats] = citem[i].id;
|
||||||
|
// numofcheats++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (numofcheats)
|
||||||
|
// err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, numofcheats, id, kDataBrowserItemNoProperty);
|
||||||
|
//
|
||||||
|
// delete [] id;
|
||||||
|
//
|
||||||
|
// cid.signature = kNewButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// if (numofcheats == MAC_MAX_CHEATS)
|
||||||
|
// err = DeactivateControl(ctl);
|
||||||
|
// else
|
||||||
|
// err = ActivateControl(ctl);
|
||||||
|
//
|
||||||
|
// cid.signature = kAllButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// if (numofcheats == 0)
|
||||||
|
// err = DeactivateControl(ctl);
|
||||||
|
// else
|
||||||
|
// err = ActivateControl(ctl);
|
||||||
|
//
|
||||||
|
// cid.signature = kDelButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// err = DeactivateControl(ctl);
|
||||||
|
//
|
||||||
|
// eUPP = NewEventHandlerUPP(CheatEventHandler);
|
||||||
|
// err = InstallWindowEventHandler(wRef, eUPP, GetEventTypeCount(events), events, (void *) wRef, &eref);
|
||||||
|
//
|
||||||
|
// err = SetKeyboardFocus(wRef, dbRef, kControlFocusNextPart);
|
||||||
|
//
|
||||||
|
// MoveWindowPosition(wRef, kWindowCheatEntry, true);
|
||||||
|
// ShowWindow(wRef);
|
||||||
|
// err = RunAppModalLoopForWindow(wRef);
|
||||||
|
// HideWindow(wRef);
|
||||||
|
// SaveWindowPosition(wRef, kWindowCheatEntry);
|
||||||
|
//
|
||||||
|
// err = RemoveEventHandler(eref);
|
||||||
|
// DisposeEventHandlerUPP(eUPP);
|
||||||
|
//
|
||||||
|
// DisposeDataBrowserItemNotificationUPP(callbacks.u.v1.itemNotificationCallback);
|
||||||
|
// DisposeDataBrowserItemCompareUPP(callbacks.u.v1.itemCompareCallback);
|
||||||
|
// DisposeDataBrowserItemDataUPP(callbacks.u.v1.itemDataCallback);
|
||||||
|
//
|
||||||
|
// CFRelease(wRef);
|
||||||
|
//
|
||||||
|
// DetachCheatItems();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// DisposeNibReference(nibRef);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AddCheatItem (void)
|
||||||
|
{
|
||||||
|
// OSStatus err;
|
||||||
|
// HIViewRef ctl, root;
|
||||||
|
// HIViewID cid;
|
||||||
|
// DataBrowserItemID id[1];
|
||||||
|
// unsigned int i;
|
||||||
|
//
|
||||||
|
// if (numofcheats == MAC_MAX_CHEATS)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// for (i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
|
// if (citem[i].valid == false)
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// if (i == MAC_MAX_CHEATS)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// numofcheats++;
|
||||||
|
// citem[i].valid = true;
|
||||||
|
// citem[i].enabled = false;
|
||||||
|
// citem[i].address = 0;
|
||||||
|
// citem[i].value = 0;
|
||||||
|
// sprintf(citem[i].description, "Cheat %03" PRIu32, citem[i].id);
|
||||||
|
//
|
||||||
|
// id[0] = citem[i].id;
|
||||||
|
// err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, 1, id, kDataBrowserItemNoProperty);
|
||||||
|
// err = RevealDataBrowserItem(dbRef, id[0], kCmAddress, true);
|
||||||
|
//
|
||||||
|
// root = HIViewGetRoot(wRef);
|
||||||
|
// cid.id = 0;
|
||||||
|
//
|
||||||
|
// if (numofcheats == MAC_MAX_CHEATS)
|
||||||
|
// {
|
||||||
|
// cid.signature = kNewButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// err = DeactivateControl(ctl);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (numofcheats)
|
||||||
|
// {
|
||||||
|
// cid.signature = kAllButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// err = ActivateControl(ctl);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DeleteCheatItem (void)
|
||||||
|
{
|
||||||
|
// OSStatus err;
|
||||||
|
// HIViewRef ctl, root;
|
||||||
|
// HIViewID cid;
|
||||||
|
// Handle selectedItems;
|
||||||
|
// ItemCount selectionCount;
|
||||||
|
//
|
||||||
|
// selectedItems = NewHandle(0);
|
||||||
|
// if (!selectedItems)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// err = GetDataBrowserItems(dbRef, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, selectedItems);
|
||||||
|
// selectionCount = (GetHandleSize(selectedItems) / sizeof(DataBrowserItemID));
|
||||||
|
//
|
||||||
|
// if (selectionCount == 0)
|
||||||
|
// {
|
||||||
|
// DisposeHandle(selectedItems);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// err = RemoveDataBrowserItems(dbRef, kDataBrowserNoItem, selectionCount, (DataBrowserItemID *) *selectedItems, kDataBrowserItemNoProperty);
|
||||||
|
//
|
||||||
|
// for (unsigned int i = 0; i < selectionCount; i++)
|
||||||
|
// {
|
||||||
|
// citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].valid = false;
|
||||||
|
// citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].enabled = false;
|
||||||
|
// numofcheats--;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// DisposeHandle(selectedItems);
|
||||||
|
//
|
||||||
|
// root = HIViewGetRoot(wRef);
|
||||||
|
// cid.id = 0;
|
||||||
|
//
|
||||||
|
// if (numofcheats < MAC_MAX_CHEATS)
|
||||||
|
// {
|
||||||
|
// cid.signature = kNewButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// err = ActivateControl(ctl);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (numofcheats == 0)
|
||||||
|
// {
|
||||||
|
// cid.signature = kAllButton;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// err = DeactivateControl(ctl);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EnableAllCheatItems (void)
|
||||||
|
{
|
||||||
|
// OSStatus err;
|
||||||
|
//
|
||||||
|
// for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
|
// if (citem[i].valid)
|
||||||
|
// citem[i].enabled = true;
|
||||||
|
//
|
||||||
|
// err = UpdateDataBrowserItems(dbRef, kDataBrowserNoItem, kDataBrowserNoItem, NULL, kDataBrowserItemNoProperty, kCmCheckBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSStatus DBClientDataCallback (HIViewRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue)
|
||||||
|
{
|
||||||
|
// OSStatus err, result;
|
||||||
|
// CFStringRef str;
|
||||||
|
// Boolean r;
|
||||||
|
// uint32 address;
|
||||||
|
// uint8 value;
|
||||||
|
// char code[256];
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
//
|
||||||
|
// switch (property)
|
||||||
|
// {
|
||||||
|
// case kCmCheckBox:
|
||||||
|
// ThemeButtonValue buttonValue;
|
||||||
|
//
|
||||||
|
// if (changeValue)
|
||||||
|
// {
|
||||||
|
// err = GetDataBrowserItemDataButtonValue(itemData, &buttonValue);
|
||||||
|
// citem[itemID - 1].enabled = (buttonValue == kThemeButtonOn) ? true : false;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// err = SetDataBrowserItemDataButtonValue(itemData, citem[itemID - 1].enabled ? kThemeButtonOn : kThemeButtonOff);
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kCmAddress:
|
||||||
|
// if (changeValue)
|
||||||
|
// {
|
||||||
|
// err = GetDataBrowserItemDataText(itemData, &str);
|
||||||
|
// r = CFStringGetCString(str, code, 256, CFStringGetSystemEncoding());
|
||||||
|
// CFRelease(str);
|
||||||
|
// if (r)
|
||||||
|
// {
|
||||||
|
// Boolean translated;
|
||||||
|
//
|
||||||
|
// if (S9xProActionReplayToRaw(code, address, value) == NULL)
|
||||||
|
// translated = true;
|
||||||
|
// else
|
||||||
|
// if (S9xGameGenieToRaw(code, address, value) == NULL)
|
||||||
|
// translated = true;
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// translated = false;
|
||||||
|
// if (sscanf(code, "%" SCNx32, &address) != 1)
|
||||||
|
// address = 0;
|
||||||
|
// else
|
||||||
|
// address &= 0xFFFFFF;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// citem[itemID - 1].address = address;
|
||||||
|
// sprintf(code, "%06" PRIX32, address);
|
||||||
|
// str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
||||||
|
// err = SetDataBrowserItemDataText(itemData, str);
|
||||||
|
// CFRelease(str);
|
||||||
|
//
|
||||||
|
// if (translated)
|
||||||
|
// {
|
||||||
|
// DataBrowserItemID id[1];
|
||||||
|
//
|
||||||
|
// citem[itemID - 1].value = value;
|
||||||
|
// id[0] = itemID;
|
||||||
|
// err = UpdateDataBrowserItems(browser, kDataBrowserNoItem, 1, id, kDataBrowserItemNoProperty, kCmValue);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// sprintf(code, "%06" PRIX32, citem[itemID - 1].address);
|
||||||
|
// str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
||||||
|
// err = SetDataBrowserItemDataText(itemData, str);
|
||||||
|
// CFRelease(str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kCmValue:
|
||||||
|
// if (changeValue)
|
||||||
|
// {
|
||||||
|
// err = GetDataBrowserItemDataText(itemData, &str);
|
||||||
|
// r = CFStringGetCString(str, code, 256, CFStringGetSystemEncoding());
|
||||||
|
// CFRelease(str);
|
||||||
|
// if (r)
|
||||||
|
// {
|
||||||
|
// uint32 byte;
|
||||||
|
//
|
||||||
|
// if (sscanf(code, "%" SCNx32, &byte) == 1)
|
||||||
|
// citem[itemID - 1].value = (uint8) byte;
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// citem[itemID - 1].value = 0;
|
||||||
|
// err = SetDataBrowserItemDataText(itemData, CFSTR("00"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// sprintf(code, "%02" PRIX8, citem[itemID - 1].value);
|
||||||
|
// str = CFStringCreateWithCString(kCFAllocatorDefault, code, CFStringGetSystemEncoding());
|
||||||
|
// err = SetDataBrowserItemDataText(itemData, str);
|
||||||
|
// CFRelease(str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kCmDescription:
|
||||||
|
// if (changeValue)
|
||||||
|
// {
|
||||||
|
// code[0] = 0;
|
||||||
|
// err = GetDataBrowserItemDataText(itemData, &str);
|
||||||
|
// strcpy(code, GetMultiByteCharacters(str, 19));
|
||||||
|
// CFRelease(str);
|
||||||
|
//
|
||||||
|
// if (code[0] == 0)
|
||||||
|
// {
|
||||||
|
// code[0] = ' ';
|
||||||
|
// code[1] = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// strcpy(citem[itemID - 1].description, code);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// str = CFStringCreateWithCString(kCFAllocatorDefault, citem[itemID - 1].description, CFStringGetSystemEncoding());
|
||||||
|
// err = SetDataBrowserItemDataText(itemData, str);
|
||||||
|
// CFRelease(str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kDataBrowserItemIsActiveProperty:
|
||||||
|
// err = SetDataBrowserItemDataBooleanValue(itemData, true);
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kDataBrowserItemIsEditableProperty:
|
||||||
|
// err = SetDataBrowserItemDataBooleanValue(itemData, true);
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// default:
|
||||||
|
// result = errDataBrowserPropertyNotSupported;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (result);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static OSStatus CheatEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
|
||||||
|
{
|
||||||
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
|
// WindowRef tWindowRef;
|
||||||
|
//
|
||||||
|
// tWindowRef = (WindowRef) inUserData;
|
||||||
|
//
|
||||||
|
// switch (GetEventClass(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventClassWindow:
|
||||||
|
// switch (GetEventKind(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventWindowClose:
|
||||||
|
// QuitAppModalLoopForWindow(tWindowRef);
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kEventClassCommand:
|
||||||
|
// switch (GetEventKind(inEvent))
|
||||||
|
// {
|
||||||
|
// HICommand tHICommand;
|
||||||
|
//
|
||||||
|
// case kEventCommandUpdateStatus:
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
|
// if (err == noErr && tHICommand.commandID == 'clos')
|
||||||
|
// {
|
||||||
|
// UpdateMenuCommandStatus(true);
|
||||||
|
// result = noErr;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kEventCommandProcess:
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// switch (tHICommand.commandID)
|
||||||
|
// {
|
||||||
|
// case kNewButton:
|
||||||
|
// AddCheatItem();
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kDelButton:
|
||||||
|
// DeleteCheatItem();
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case kAllButton:
|
||||||
|
// EnableAllCheatItems();
|
||||||
|
// result = noErr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (result);
|
||||||
|
return 0;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -740,7 +740,7 @@ static bool8 NPClientBeginOpenROMImage (WindowRef window)
|
||||||
replaceAt = CFStringGetIntValue(numRef);
|
replaceAt = CFStringGetIntValue(numRef);
|
||||||
CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);
|
CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);
|
||||||
|
|
||||||
r = NavBeginOpenROMImageSheet(window, mesRef);
|
// r = NavBeginOpenROMImageSheet(window, mesRef);
|
||||||
|
|
||||||
CFRelease(mesRef);
|
CFRelease(mesRef);
|
||||||
CFRelease(baseRef);
|
CFRelease(baseRef);
|
|
@ -25,14 +25,13 @@
|
||||||
|
|
||||||
void CocoaPlayFreezeDefrostSound (void)
|
void CocoaPlayFreezeDefrostSound (void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
|
||||||
NSBundle *bundle;
|
NSBundle *bundle;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
NSSound *sound;
|
NSSound *sound;
|
||||||
BOOL r;
|
BOOL r;
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
@autoreleasepool
|
||||||
|
{
|
||||||
bundle = [NSBundle mainBundle];
|
bundle = [NSBundle mainBundle];
|
||||||
path = [bundle pathForSoundResource: @"freeze_defrost"];
|
path = [bundle pathForSoundResource: @"freeze_defrost"];
|
||||||
if (path)
|
if (path)
|
||||||
|
@ -41,21 +40,19 @@ void CocoaPlayFreezeDefrostSound (void)
|
||||||
if (sound)
|
if (sound)
|
||||||
{
|
{
|
||||||
r = [sound play];
|
r = [sound play];
|
||||||
[sound release];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocoaAddStatTextToView (NSView *view, NSString *label, float x, float y, float w, float h, NSTextField **out)
|
void CocoaAddStatTextToView (NSView *view, NSString *label, float x, float y, float w, float h, NSTextField **out)
|
||||||
{
|
{
|
||||||
NSTextField *control;
|
NSTextField *control;
|
||||||
|
|
||||||
control = [[[NSTextField alloc] init] autorelease];
|
control = [[NSTextField alloc] init];
|
||||||
|
|
||||||
[[control cell] setControlSize: NSSmallControlSize];
|
[[control cell] setControlSize: NSControlSizeSmall];
|
||||||
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
|
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSControlSizeSmall]]];
|
||||||
[control setStringValue: NSLocalizedString(label, @"")];
|
[control setStringValue: NSLocalizedString(label, @"")];
|
||||||
[control setBezeled: NO];
|
[control setBezeled: NO];
|
||||||
[control setDrawsBackground: NO];
|
[control setDrawsBackground: NO];
|
||||||
|
@ -73,10 +70,10 @@ void CocoaAddEditTextToView (NSView *view, NSString *label, float x, float y, fl
|
||||||
{
|
{
|
||||||
NSTextField *control;
|
NSTextField *control;
|
||||||
|
|
||||||
control = [[[NSTextField alloc] init] autorelease];
|
control = [[NSTextField alloc] init];
|
||||||
|
|
||||||
[[control cell] setControlSize: NSSmallControlSize];
|
[[control cell] setControlSize: NSControlSizeSmall];
|
||||||
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
|
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSControlSizeSmall]]];
|
||||||
[control setStringValue: NSLocalizedString(label, @"")];
|
[control setStringValue: NSLocalizedString(label, @"")];
|
||||||
[control setBezeled: YES];
|
[control setBezeled: YES];
|
||||||
[control setDrawsBackground: YES];
|
[control setDrawsBackground: YES];
|
||||||
|
@ -94,13 +91,13 @@ void CocoaAddMPushBtnToView (NSView *view, NSString *label, float x, float y, fl
|
||||||
{
|
{
|
||||||
NSButton *control;
|
NSButton *control;
|
||||||
|
|
||||||
control = [[[NSButton alloc] init] autorelease];
|
control = [[NSButton alloc] init];
|
||||||
|
|
||||||
[[control cell] setControlSize: NSSmallControlSize];
|
[[control cell] setControlSize: NSControlSizeSmall];
|
||||||
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
|
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSControlSizeSmall]]];
|
||||||
[control setTitle: NSLocalizedString(label, @"")];
|
[control setTitle: NSLocalizedString(label, @"")];
|
||||||
[control setBezelStyle: NSRoundedBezelStyle];
|
[control setBezelStyle: NSBezelStyleRounded];
|
||||||
[control setButtonType: NSMomentaryPushInButton];
|
[control setButtonType: NSButtonTypeMomentaryPushIn];
|
||||||
|
|
||||||
[view addSubview: control];
|
[view addSubview: control];
|
||||||
[control setFrame: NSMakeRect(x, y, w, h)];
|
[control setFrame: NSMakeRect(x, y, w, h)];
|
||||||
|
@ -113,12 +110,12 @@ void CocoaAddCheckBoxToView (NSView *view, NSString *label, float x, float y, fl
|
||||||
{
|
{
|
||||||
NSButton *control;
|
NSButton *control;
|
||||||
|
|
||||||
control = [[[NSButton alloc] init] autorelease];
|
control = [[NSButton alloc] init];
|
||||||
|
|
||||||
[[control cell] setControlSize: NSSmallControlSize];
|
[[control cell] setControlSize: NSControlSizeSmall];
|
||||||
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
|
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSControlSizeSmall]]];
|
||||||
[control setTitle: NSLocalizedString(label, @"")];
|
[control setTitle: NSLocalizedString(label, @"")];
|
||||||
[control setButtonType: NSSwitchButton];
|
[control setButtonType: NSButtonTypeSwitch];
|
||||||
|
|
||||||
[view addSubview: control];
|
[view addSubview: control];
|
||||||
[control setFrame: NSMakeRect(x, y, w, h)];
|
[control setFrame: NSMakeRect(x, y, w, h)];
|
||||||
|
@ -133,7 +130,7 @@ void CocoaAddPopUpBtnToView (NSView *view, NSArray *array, float x, float y, flo
|
||||||
NSMenu *menu;
|
NSMenu *menu;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
menu = [[[NSMenu alloc] init] autorelease];
|
menu = [[NSMenu alloc] init];
|
||||||
|
|
||||||
n = [array count];
|
n = [array count];
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
|
@ -145,10 +142,10 @@ void CocoaAddPopUpBtnToView (NSView *view, NSArray *array, float x, float y, flo
|
||||||
[menu addItemWithTitle: item action: NULL keyEquivalent: @""];
|
[menu addItemWithTitle: item action: NULL keyEquivalent: @""];
|
||||||
}
|
}
|
||||||
|
|
||||||
control = [[[NSPopUpButton alloc] init] autorelease];
|
control = [[NSPopUpButton alloc] init];
|
||||||
|
|
||||||
[[control cell] setControlSize: NSSmallControlSize];
|
[[control cell] setControlSize: NSControlSizeSmall];
|
||||||
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
|
[control setFont: [NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize: NSControlSizeSmall]]];
|
||||||
[control setPullsDown: NO];
|
[control setPullsDown: NO];
|
||||||
[control setMenu: menu];
|
[control setMenu: menu];
|
||||||
|
|
||||||
|
|
|
@ -175,56 +175,56 @@ void S9xSetupDefaultKeymap (void)
|
||||||
|
|
||||||
bool S9xPollButton (uint32 id, bool *pressed)
|
bool S9xPollButton (uint32 id, bool *pressed)
|
||||||
{
|
{
|
||||||
#define kmControlKey 0x3B
|
// #define kmControlKey 0x3B
|
||||||
|
//
|
||||||
KeyMap keys;
|
// KeyMap keys;
|
||||||
|
//
|
||||||
GetKeys(keys);
|
// GetKeys(keys);
|
||||||
|
//
|
||||||
*pressed = false;
|
// *pressed = false;
|
||||||
|
//
|
||||||
if (id & k_MO) // mouse
|
// if (id & k_MO) // mouse
|
||||||
{
|
// {
|
||||||
switch (id & 0xFF)
|
// switch (id & 0xFF)
|
||||||
{
|
// {
|
||||||
case 0: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
// case 0: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
||||||
case 1: *pressed = ISpKeyIsPressed(kISpMouseR);
|
// case 1: *pressed = ISpKeyIsPressed(kISpMouseR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
if (id & k_SS) // superscope
|
// if (id & k_SS) // superscope
|
||||||
{
|
// {
|
||||||
switch (id & 0xFF)
|
// switch (id & 0xFF)
|
||||||
{
|
// {
|
||||||
case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
// case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
||||||
case 2: *pressed = ISpKeyIsPressed(kISpScopeC) | KeyIsPressed(keys, keyCode[kKeyScopeCursor]); break;
|
// case 2: *pressed = ISpKeyIsPressed(kISpScopeC) | KeyIsPressed(keys, keyCode[kKeyScopeCursor]); break;
|
||||||
case 3: *pressed = ISpKeyIsPressed(kISpScopeT) | KeyIsPressed(keys, keyCode[kKeyScopeTurbo]); break;
|
// case 3: *pressed = ISpKeyIsPressed(kISpScopeT) | KeyIsPressed(keys, keyCode[kKeyScopeTurbo]); break;
|
||||||
case 4: *pressed = ISpKeyIsPressed(kISpScopeP) | KeyIsPressed(keys, keyCode[kKeyScopePause]); break;
|
// case 4: *pressed = ISpKeyIsPressed(kISpScopeP) | KeyIsPressed(keys, keyCode[kKeyScopePause]); break;
|
||||||
case 1: *pressed = ISpKeyIsPressed(kISpMouseL);
|
// case 1: *pressed = ISpKeyIsPressed(kISpMouseL);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
if (id & k_LG) // justifier
|
// if (id & k_LG) // justifier
|
||||||
{
|
// {
|
||||||
if (id & k_C1)
|
// if (id & k_C1)
|
||||||
{
|
// {
|
||||||
switch (id & 0xFF)
|
// switch (id & 0xFF)
|
||||||
{
|
// {
|
||||||
case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
// case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
||||||
case 1: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
// case 1: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
||||||
case 2: *pressed = ISpKeyIsPressed(kISpMouseR);
|
// case 2: *pressed = ISpKeyIsPressed(kISpMouseR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
switch (id & 0xFF)
|
// switch (id & 0xFF)
|
||||||
{
|
// {
|
||||||
case 0: *pressed = ISpKeyIsPressed(kISp2PStart) | KeyIsPressed(keys, keyCode[k2PStart]); break;
|
// case 0: *pressed = ISpKeyIsPressed(kISp2PStart) | KeyIsPressed(keys, keyCode[k2PStart]); break;
|
||||||
case 1: *pressed = ISpKeyIsPressed(kISp2PB) | KeyIsPressed(keys, keyCode[k2PB]); break;
|
// case 1: *pressed = ISpKeyIsPressed(kISp2PB) | KeyIsPressed(keys, keyCode[k2PB]); break;
|
||||||
case 2: *pressed = ISpKeyIsPressed(kISp2PA) | KeyIsPressed(keys, keyCode[k2PA]);
|
// case 2: *pressed = ISpKeyIsPressed(kISp2PA) | KeyIsPressed(keys, keyCode[k2PA]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
|
@ -78,7 +78,7 @@ static CFStringRef ciFilterName = NULL;
|
||||||
static HIViewRef ciFilterUIPane = NULL;
|
static HIViewRef ciFilterUIPane = NULL;
|
||||||
static MenuRef ciFilterMenu = NULL;
|
static MenuRef ciFilterMenu = NULL;
|
||||||
static CGColorSpaceRef cgColor = NULL;
|
static CGColorSpaceRef cgColor = NULL;
|
||||||
static MPSemaphoreID cisem = NULL;
|
static dispatch_semaphore_t cisem = NULL;
|
||||||
static bool8 ciFilterHasInputCenter = false;
|
static bool8 ciFilterHasInputCenter = false;
|
||||||
static bool8 ciFilterHasInputImage = false;
|
static bool8 ciFilterHasInputImage = false;
|
||||||
static int ciFilterInputKeysCount = 0;
|
static int ciFilterInputKeysCount = 0;
|
||||||
|
@ -98,50 +98,35 @@ static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef, EventRef, void
|
||||||
|
|
||||||
void InitCoreImage (void)
|
void InitCoreImage (void)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
@autoreleasepool
|
||||||
NSAutoreleasePool *pool;
|
{
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
ciFilterName = (CFStringRef) CFPreferencesCopyAppValue(kCIFilterNamePrefKey, kCFPreferencesCurrentApplication);
|
ciFilterName = (CFStringRef) CFPreferencesCopyAppValue(kCIFilterNamePrefKey, kCFPreferencesCurrentApplication);
|
||||||
if (!ciFilterName)
|
if (!ciFilterName)
|
||||||
ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("CIGammaAdjust"));
|
ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("CIGammaAdjust"));
|
||||||
|
|
||||||
BuildCoreImageFilterListAndMenu();
|
BuildCoreImageFilterListAndMenu();
|
||||||
|
|
||||||
err = MPCreateBinarySemaphore(&cisem);
|
cisem = dispatch_semaphore_create(0);
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeinitCoreImage (void)
|
void DeinitCoreImage (void)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
|
||||||
NSAutoreleasePool *pool;
|
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
err = MPDeleteSemaphore(cisem);
|
|
||||||
|
|
||||||
ReleaseCoreImageFilterListAndMenu();
|
ReleaseCoreImageFilterListAndMenu();
|
||||||
|
|
||||||
CFPreferencesSetAppValue(kCIFilterNamePrefKey, ciFilterName, kCFPreferencesCurrentApplication);
|
CFPreferencesSetAppValue(kCIFilterNamePrefKey, ciFilterName, kCFPreferencesCurrentApplication);
|
||||||
|
|
||||||
CFRelease(ciFilterName);
|
CFRelease(ciFilterName);
|
||||||
|
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitCoreImageFilter (void)
|
void InitCoreImageFilter (void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
@autoreleasepool
|
||||||
|
{
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
ciFilter = [CIFilter filterWithName: (__bridge NSString *) ciFilterName];
|
||||||
|
|
||||||
ciFilter = [[CIFilter filterWithName: (NSString *) ciFilterName] retain];
|
|
||||||
[ciFilter setDefaults];
|
[ciFilter setDefaults];
|
||||||
|
|
||||||
ciFilterInputKeys = [[ciFilter inputKeys] retain];
|
ciFilterInputKeys = [ciFilter inputKeys];
|
||||||
ciFilterInputKeysCount = [ciFilterInputKeys count];
|
ciFilterInputKeysCount = [ciFilterInputKeys count];
|
||||||
|
|
||||||
ciFilterParam = new FilterParam [ciFilterInputKeysCount];
|
ciFilterParam = new FilterParam [ciFilterInputKeysCount];
|
||||||
|
@ -151,16 +136,13 @@ void InitCoreImageFilter (void)
|
||||||
ciFilterHasInputImage = false;
|
ciFilterHasInputImage = false;
|
||||||
|
|
||||||
LoadFilterPrefs();
|
LoadFilterPrefs();
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeinitCoreImageFilter (void)
|
void DeinitCoreImageFilter (void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
@autoreleasepool
|
||||||
|
{
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
SaveFilterPrefs();
|
SaveFilterPrefs();
|
||||||
|
|
||||||
ciFilterHasInputCenter = false;
|
ciFilterHasInputCenter = false;
|
||||||
|
@ -168,12 +150,11 @@ void DeinitCoreImageFilter (void)
|
||||||
|
|
||||||
delete [] ciFilterParam;
|
delete [] ciFilterParam;
|
||||||
|
|
||||||
[ciFilterInputKeys release];
|
ciFilterInputKeys = nil;
|
||||||
ciFilterInputKeysCount = 0;
|
ciFilterInputKeysCount = 0;
|
||||||
|
|
||||||
[ciFilter release];
|
ciFilter = nil;
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadFilterPrefs (void)
|
static void LoadFilterPrefs (void)
|
||||||
|
@ -330,46 +311,46 @@ static void FilterToFilterParam (void)
|
||||||
|
|
||||||
static void BuildCoreImageFilterListAndMenu (void)
|
static void BuildCoreImageFilterListAndMenu (void)
|
||||||
{
|
{
|
||||||
NSArray *categories, *filterNames;
|
// NSArray *categories, *filterNames;
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
|
//
|
||||||
categories = [NSArray arrayWithObject: kCICategoryStillImage];
|
// categories = [NSArray arrayWithObject: kCICategoryStillImage];
|
||||||
filterNames = [CIFilter filterNamesInCategories: categories];
|
// filterNames = [CIFilter filterNamesInCategories: categories];
|
||||||
|
//
|
||||||
ciFilterNameList = [[NSMutableArray alloc] initWithCapacity: 1];
|
// ciFilterNameList = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
ciFilterLocalizedNameList = [[NSMutableArray alloc] initWithCapacity: 1];
|
// ciFilterLocalizedNameList = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
err = CreateNewMenu(mCoreImageFilter, 0, &ciFilterMenu);
|
// err = CreateNewMenu(mCoreImageFilter, 0, &ciFilterMenu);
|
||||||
|
//
|
||||||
int n = [filterNames count], m = 0;
|
// int n = [filterNames count], m = 0;
|
||||||
for (int i = 0; i < n; i++)
|
// for (int i = 0; i < n; i++)
|
||||||
{
|
// {
|
||||||
CIFilter *filter;
|
// CIFilter *filter;
|
||||||
NSString *name, *localName;
|
// NSString *name, *localName;
|
||||||
|
//
|
||||||
name = [filterNames objectAtIndex: i];
|
// name = [filterNames objectAtIndex: i];
|
||||||
filter = [CIFilter filterWithName: name];
|
// filter = [CIFilter filterWithName: name];
|
||||||
|
//
|
||||||
if (IsCoreImageFilterSupported(filter))
|
// if (IsCoreImageFilterSupported(filter))
|
||||||
{
|
// {
|
||||||
[ciFilterNameList addObject: name];
|
// [ciFilterNameList addObject: name];
|
||||||
|
//
|
||||||
localName = [CIFilter localizedNameForFilterName: name];
|
// localName = [CIFilter localizedNameForFilterName: name];
|
||||||
if (!localName)
|
// if (!localName)
|
||||||
localName = [NSString stringWithString: name];
|
// localName = [NSString stringWithString: name];
|
||||||
|
//
|
||||||
[ciFilterLocalizedNameList addObject: localName];
|
// [ciFilterLocalizedNameList addObject: localName];
|
||||||
|
//
|
||||||
err = AppendMenuItemTextWithCFString(ciFilterMenu, (CFStringRef) localName, 0, kCommandFilterMenuBase + m, NULL);
|
// err = AppendMenuItemTextWithCFString(ciFilterMenu, (CFStringRef) localName, 0, kCommandFilterMenuBase + m, NULL);
|
||||||
m++;
|
// m++;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseCoreImageFilterListAndMenu (void)
|
static void ReleaseCoreImageFilterListAndMenu (void)
|
||||||
{
|
{
|
||||||
CFRelease(ciFilterMenu);
|
CFRelease(ciFilterMenu);
|
||||||
[ciFilterLocalizedNameList release];
|
ciFilterLocalizedNameList = nil;
|
||||||
[ciFilterNameList release];
|
ciFilterNameList = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 IsCoreImageFilterSupported (CIFilter *filter)
|
static bool8 IsCoreImageFilterSupported (CIFilter *filter)
|
||||||
|
@ -420,407 +401,396 @@ static bool8 IsCoreImageFilterSupported (CIFilter *filter)
|
||||||
|
|
||||||
void ConfigureCoreImageFilter (void)
|
void ConfigureCoreImageFilter (void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
// NSAutoreleasePool *pool;
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
IBNibRef nibRef;
|
// IBNibRef nibRef;
|
||||||
|
//
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
// pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
//
|
||||||
err = CreateNibReference(kMacS9XCFString, &nibRef);
|
// err = CreateNibReference(kMacS9XCFString, &nibRef);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
WindowRef window;
|
// WindowRef window;
|
||||||
|
//
|
||||||
err = CreateWindowFromNib(nibRef, CFSTR("CIFilter"), &window);
|
// err = CreateWindowFromNib(nibRef, CFSTR("CIFilter"), &window);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
EventHandlerRef eref;
|
// EventHandlerRef eref;
|
||||||
EventHandlerUPP eUPP;
|
// EventHandlerUPP eUPP;
|
||||||
EventTypeSpec event[] = { { kEventClassWindow, kEventWindowClose },
|
// EventTypeSpec event[] = { { kEventClassWindow, kEventWindowClose },
|
||||||
{ kEventClassCommand, kEventCommandProcess },
|
// { kEventClassCommand, kEventCommandProcess },
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } };
|
// { kEventClassCommand, kEventCommandUpdateStatus } };
|
||||||
HIViewRef ctl, root;
|
// HIViewRef ctl, root;
|
||||||
HIViewID cid;
|
// HIViewID cid;
|
||||||
Rect rct;
|
// Rect rct;
|
||||||
int value;
|
// int value;
|
||||||
|
//
|
||||||
ciFilterUIPane = NULL;
|
// ciFilterUIPane = NULL;
|
||||||
|
//
|
||||||
FilterToFilterParam();
|
// FilterToFilterParam();
|
||||||
|
//
|
||||||
root = HIViewGetRoot(window);
|
// root = HIViewGetRoot(window);
|
||||||
|
//
|
||||||
SetHIViewID(&cid, 'FILT', 0);
|
// SetHIViewID(&cid, 'FILT', 0);
|
||||||
rct.left = 74;
|
// rct.left = 74;
|
||||||
rct.top = 20;
|
// rct.top = 20;
|
||||||
rct.right = 74 + 279;
|
// rct.right = 74 + 279;
|
||||||
rct.bottom = 20 + 20;
|
// rct.bottom = 20 + 20;
|
||||||
err = CreatePopupButtonControl(window, &rct, NULL, -12345, false, 0, 0, 0, &ctl);
|
// err = CreatePopupButtonControl(window, &rct, NULL, -12345, false, 0, 0, 0, &ctl);
|
||||||
HIViewSetID(ctl, cid);
|
// HIViewSetID(ctl, cid);
|
||||||
int n = CountMenuItems(ciFilterMenu);
|
// int n = CountMenuItems(ciFilterMenu);
|
||||||
SetControlPopupMenuHandle(ctl, ciFilterMenu);
|
// SetControlPopupMenuHandle(ctl, ciFilterMenu);
|
||||||
HIViewSetMaximum(ctl, n);
|
// HIViewSetMaximum(ctl, n);
|
||||||
value = [ciFilterNameList indexOfObject: (NSString *) ciFilterName];
|
// value = [ciFilterNameList indexOfObject: (NSString *) ciFilterName];
|
||||||
HIViewSetValue(ctl, value + 1);
|
// HIViewSetValue(ctl, value + 1);
|
||||||
|
//
|
||||||
ReplaceFilterUI(window);
|
// ReplaceFilterUI(window);
|
||||||
|
//
|
||||||
eUPP = NewEventHandlerUPP(CoreImageFilterEventHandler);
|
// eUPP = NewEventHandlerUPP(CoreImageFilterEventHandler);
|
||||||
err = InstallWindowEventHandler(window, eUPP, GetEventTypeCount(event), event, (void *) window, &eref);
|
// err = InstallWindowEventHandler(window, eUPP, GetEventTypeCount(event), event, (void *) window, &eref);
|
||||||
|
//
|
||||||
MoveWindowPosition(window, kWindowCoreImageFilter, false);
|
// MoveWindowPosition(window, kWindowCoreImageFilter, false);
|
||||||
ShowWindow(window);
|
// ShowWindow(window);
|
||||||
err = RunAppModalLoopForWindow(window);
|
// err = RunAppModalLoopForWindow(window);
|
||||||
HideWindow(window);
|
// HideWindow(window);
|
||||||
SaveWindowPosition(window, kWindowCoreImageFilter);
|
// SaveWindowPosition(window, kWindowCoreImageFilter);
|
||||||
|
//
|
||||||
err = RemoveEventHandler(eref);
|
// err = RemoveEventHandler(eref);
|
||||||
DisposeEventHandlerUPP(eUPP);
|
// DisposeEventHandlerUPP(eUPP);
|
||||||
|
//
|
||||||
FilterParamToFilter();
|
// FilterParamToFilter();
|
||||||
|
//
|
||||||
CFRelease(window);
|
// CFRelease(window);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
DisposeNibReference(nibRef);
|
// DisposeNibReference(nibRef);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
[pool release];
|
// [pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReplaceFilterUI (WindowRef window)
|
static void ReplaceFilterUI (WindowRef window)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
HIRect frame;
|
// HIRect frame;
|
||||||
Rect bounds, rct;
|
// Rect bounds, rct;
|
||||||
|
//
|
||||||
if (ciFilterUIPane)
|
// if (ciFilterUIPane)
|
||||||
{
|
// {
|
||||||
HIViewSetVisible(ciFilterUIPane, false);
|
// HIViewSetVisible(ciFilterUIPane, false);
|
||||||
DisposeControl(ciFilterUIPane);
|
// DisposeControl(ciFilterUIPane);
|
||||||
ciFilterUIPane = NULL;
|
// ciFilterUIPane = NULL;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
GetWindowBounds(window, kWindowStructureRgn, &bounds);
|
// GetWindowBounds(window, kWindowStructureRgn, &bounds);
|
||||||
|
//
|
||||||
rct.left = 15;
|
// rct.left = 15;
|
||||||
rct.right = bounds.right - bounds.left - 15;
|
// rct.right = bounds.right - bounds.left - 15;
|
||||||
rct.top = 81;
|
// rct.top = 81;
|
||||||
rct.bottom = rct.top + 40;
|
// rct.bottom = rct.top + 40;
|
||||||
err = CreateUserPaneControl(window, &rct, kControlSupportsEmbedding, &ciFilterUIPane);
|
// err = CreateUserPaneControl(window, &rct, kControlSupportsEmbedding, &ciFilterUIPane);
|
||||||
HIViewSetVisible(ciFilterUIPane, false);
|
// HIViewSetVisible(ciFilterUIPane, false);
|
||||||
FilterUIAddSubviews(window, ciFilterUIPane);
|
// FilterUIAddSubviews(window, ciFilterUIPane);
|
||||||
|
//
|
||||||
HIViewGetFrame(ciFilterUIPane, &frame);
|
// HIViewGetFrame(ciFilterUIPane, &frame);
|
||||||
bounds.bottom = bounds.top + (short) (frame.origin.y + frame.size.height + 30);
|
// bounds.bottom = bounds.top + (short) (frame.origin.y + frame.size.height + 30);
|
||||||
|
//
|
||||||
err = TransitionWindow(window, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &bounds);
|
// err = TransitionWindow(window, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &bounds);
|
||||||
HIViewSetVisible(ciFilterUIPane, true);
|
// HIViewSetVisible(ciFilterUIPane, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FilterUIAddSubviews (WindowRef window, HIViewRef parent)
|
static void FilterUIAddSubviews (WindowRef window, HIViewRef parent)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
CFMutableStringRef label;
|
// CFMutableStringRef label;
|
||||||
CFStringRef str;
|
// CFStringRef str;
|
||||||
HIViewRef ctl;
|
// HIViewRef ctl;
|
||||||
HIViewID cid;
|
// HIViewID cid;
|
||||||
HIRect bounds, frame;
|
// HIRect bounds, frame;
|
||||||
Rect rct;
|
// Rect rct;
|
||||||
SInt32 value;
|
// SInt32 value;
|
||||||
|
//
|
||||||
HIViewGetFrame(parent, &bounds);
|
// HIViewGetFrame(parent, &bounds);
|
||||||
rct.left = 0;
|
// rct.left = 0;
|
||||||
rct.top = 0;
|
// rct.top = 0;
|
||||||
rct.right = 200;
|
// rct.right = 200;
|
||||||
rct.bottom = 20;
|
// rct.bottom = 20;
|
||||||
|
//
|
||||||
int m = 0;
|
// int m = 0;
|
||||||
for (int i = 0; i < ciFilterInputKeysCount; i++)
|
// for (int i = 0; i < ciFilterInputKeysCount; i++)
|
||||||
{
|
// {
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, ciFilterParam[i].displayName, kCFStringEncodingUTF8);
|
// str = CFStringCreateWithCString(kCFAllocatorDefault, ciFilterParam[i].displayName, kCFStringEncodingUTF8);
|
||||||
if (!str)
|
// if (!str)
|
||||||
str = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("Parameter"));
|
// str = CFStringCreateCopy(kCFAllocatorDefault, CFSTR("Parameter"));
|
||||||
label = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, str);
|
// label = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, str);
|
||||||
CFRelease(str);
|
// CFRelease(str);
|
||||||
|
//
|
||||||
switch (ciFilterParam[i].type)
|
// switch (ciFilterParam[i].type)
|
||||||
{
|
// {
|
||||||
case kCITypeBoolean:
|
// case kCITypeBoolean:
|
||||||
{
|
// {
|
||||||
err = CreateCheckBoxControl(window, &rct, label, ciFilterParam[i].u.b.cur, true, &ctl);
|
// err = CreateCheckBoxControl(window, &rct, label, ciFilterParam[i].u.b.cur, true, &ctl);
|
||||||
SetHIViewID(&cid, kCommandCheckBoxBase + i, i);
|
// SetHIViewID(&cid, kCommandCheckBoxBase + i, i);
|
||||||
HIViewSetID(ctl, cid);
|
// HIViewSetID(ctl, cid);
|
||||||
HIViewSetCommandID(ctl, cid.signature);
|
// HIViewSetCommandID(ctl, cid.signature);
|
||||||
err = HIViewAddSubview(parent, ctl);
|
// err = HIViewAddSubview(parent, ctl);
|
||||||
frame.origin.x = 5.0f;
|
// frame.origin.x = 5.0f;
|
||||||
frame.origin.y = (float) (m * 28);
|
// frame.origin.y = (float) (m * 28);
|
||||||
frame.size.width = bounds.size.width - 10.0f;
|
// frame.size.width = bounds.size.width - 10.0f;
|
||||||
frame.size.height = 20.0f;
|
// frame.size.height = 20.0f;
|
||||||
err = HIViewSetFrame(ctl, &frame);
|
// err = HIViewSetFrame(ctl, &frame);
|
||||||
m++;
|
// m++;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
case kCITypeScalar:
|
// case kCITypeScalar:
|
||||||
{
|
// {
|
||||||
CFStringAppend(label, CFSTR(" :"));
|
// CFStringAppend(label, CFSTR(" :"));
|
||||||
err = CreateStaticTextControl(window, &rct, label, NULL, &ctl);
|
// err = CreateStaticTextControl(window, &rct, label, NULL, &ctl);
|
||||||
SetStaticTextTrunc(ctl, truncEnd, true);
|
// SetStaticTextTrunc(ctl, truncEnd, true);
|
||||||
err = HIViewAddSubview(parent, ctl);
|
// err = HIViewAddSubview(parent, ctl);
|
||||||
frame.origin.x = 5.0f;
|
// frame.origin.x = 5.0f;
|
||||||
frame.origin.y = (float) (m * 28);
|
// frame.origin.y = (float) (m * 28);
|
||||||
frame.size.width = 120.0f;
|
// frame.size.width = 120.0f;
|
||||||
frame.size.height = 20.0f;
|
// frame.size.height = 20.0f;
|
||||||
err = HIViewSetFrame(ctl, &frame);
|
// err = HIViewSetFrame(ctl, &frame);
|
||||||
|
//
|
||||||
value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE);
|
// value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE);
|
||||||
err = CreateSliderControl(window, &rct, value, 0, FIXEDRANGE, kControlSliderDoesNotPoint, 0, false, NULL, &ctl);
|
// err = CreateSliderControl(window, &rct, value, 0, FIXEDRANGE, kControlSliderDoesNotPoint, 0, false, NULL, &ctl);
|
||||||
SetHIViewID(&cid, kCommandSliderBase + i, i);
|
// SetHIViewID(&cid, kCommandSliderBase + i, i);
|
||||||
HIViewSetID(ctl, cid);
|
// HIViewSetID(ctl, cid);
|
||||||
HIViewSetCommandID(ctl, cid.signature);
|
// HIViewSetCommandID(ctl, cid.signature);
|
||||||
err = HIViewAddSubview(parent, ctl);
|
// err = HIViewAddSubview(parent, ctl);
|
||||||
frame.origin.x = 135.0f;
|
// frame.origin.x = 135.0f;
|
||||||
frame.origin.y = (float) (m * 28) - 1.0f;
|
// frame.origin.y = (float) (m * 28) - 1.0f;
|
||||||
frame.size.width = bounds.size.width - 140.0f;
|
// frame.size.width = bounds.size.width - 140.0f;
|
||||||
frame.size.height = 20.0f;
|
// frame.size.height = 20.0f;
|
||||||
err = HIViewSetFrame(ctl, &frame);
|
// err = HIViewSetFrame(ctl, &frame);
|
||||||
m++;
|
// m++;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
case kCITypeColor:
|
// case kCITypeColor:
|
||||||
{
|
// {
|
||||||
CFStringAppend(label, CFSTR("..."));
|
// CFStringAppend(label, CFSTR("..."));
|
||||||
err = CreatePushButtonControl(window, &rct, label, &ctl);
|
// err = CreatePushButtonControl(window, &rct, label, &ctl);
|
||||||
SetHIViewID(&cid, kCommandColorButtonBase + i, i);
|
// SetHIViewID(&cid, kCommandColorButtonBase + i, i);
|
||||||
HIViewSetID(ctl, cid);
|
// HIViewSetID(ctl, cid);
|
||||||
HIViewSetCommandID(ctl, cid.signature);
|
// HIViewSetCommandID(ctl, cid.signature);
|
||||||
err = HIViewAddSubview(parent, ctl);
|
// err = HIViewAddSubview(parent, ctl);
|
||||||
frame.origin.x = bounds.size.width - 180.0f;
|
// frame.origin.x = bounds.size.width - 180.0f;
|
||||||
frame.origin.y = (float) (m * 28);
|
// frame.origin.y = (float) (m * 28);
|
||||||
frame.size.width = 175.0f;
|
// frame.size.width = 175.0f;
|
||||||
frame.size.height = 20.0f;
|
// frame.size.height = 20.0f;
|
||||||
err = HIViewSetFrame(ctl, &frame);
|
// err = HIViewSetFrame(ctl, &frame);
|
||||||
m++;
|
// m++;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
CFRelease(label);
|
// CFRelease(label);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (m)
|
// if (m)
|
||||||
{
|
// {
|
||||||
str = CFCopyLocalizedString(CFSTR("ResetCIFilter"), "Reset");
|
// str = CFCopyLocalizedString(CFSTR("ResetCIFilter"), "Reset");
|
||||||
err = CreatePushButtonControl(window, &rct, str, &ctl);
|
// err = CreatePushButtonControl(window, &rct, str, &ctl);
|
||||||
SetHIViewID(&cid, 'rSET', 0);
|
// SetHIViewID(&cid, 'rSET', 0);
|
||||||
HIViewSetID(ctl, cid);
|
// HIViewSetID(ctl, cid);
|
||||||
HIViewSetCommandID(ctl, cid.signature);
|
// HIViewSetCommandID(ctl, cid.signature);
|
||||||
err = HIViewAddSubview(parent, ctl);
|
// err = HIViewAddSubview(parent, ctl);
|
||||||
frame.origin.x = bounds.size.width - 180.0f;
|
// frame.origin.x = bounds.size.width - 180.0f;
|
||||||
frame.origin.y = (float) (m * 28 + 12);
|
// frame.origin.y = (float) (m * 28 + 12);
|
||||||
frame.size.width = 175.0f;
|
// frame.size.width = 175.0f;
|
||||||
frame.size.height = 20.0f;
|
// frame.size.height = 20.0f;
|
||||||
err = HIViewSetFrame(ctl, &frame);
|
// err = HIViewSetFrame(ctl, &frame);
|
||||||
CFRelease(str);
|
// CFRelease(str);
|
||||||
bounds.size.height = frame.origin.y + 32.0f;
|
// bounds.size.height = frame.origin.y + 32.0f;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
bounds.size.height = 4.0f;
|
// bounds.size.height = 4.0f;
|
||||||
|
//
|
||||||
err = HIViewSetFrame(parent, &bounds);
|
// err = HIViewSetFrame(parent, &bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FilterUISetValues (HIViewRef parent)
|
static void FilterUISetValues (HIViewRef parent)
|
||||||
{
|
{
|
||||||
HIViewRef ctl;
|
// HIViewRef ctl;
|
||||||
HIViewID cid;
|
// HIViewID cid;
|
||||||
SInt32 value;
|
// SInt32 value;
|
||||||
|
//
|
||||||
for (int i = 0; i < ciFilterInputKeysCount; i++)
|
// for (int i = 0; i < ciFilterInputKeysCount; i++)
|
||||||
{
|
// {
|
||||||
switch (ciFilterParam[i].type)
|
// switch (ciFilterParam[i].type)
|
||||||
{
|
// {
|
||||||
case kCITypeBoolean:
|
// case kCITypeBoolean:
|
||||||
SetHIViewID(&cid, kCommandCheckBoxBase + i, i);
|
// SetHIViewID(&cid, kCommandCheckBoxBase + i, i);
|
||||||
HIViewFindByID(parent, cid, &ctl);
|
// HIViewFindByID(parent, cid, &ctl);
|
||||||
HIViewSetValue(ctl, ciFilterParam[i].u.b.cur);
|
// HIViewSetValue(ctl, ciFilterParam[i].u.b.cur);
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kCITypeScalar:
|
// case kCITypeScalar:
|
||||||
value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE);
|
// value = (SInt32) ((ciFilterParam[i].u.s.cur - ciFilterParam[i].u.s.min) / (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) FIXEDRANGE);
|
||||||
SetHIViewID(&cid, kCommandSliderBase + i, i);
|
// SetHIViewID(&cid, kCommandSliderBase + i, i);
|
||||||
HIViewFindByID(parent, cid, &ctl);
|
// HIViewFindByID(parent, cid, &ctl);
|
||||||
HIViewSetValue(ctl, value);
|
// HIViewSetValue(ctl, value);
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
{
|
{
|
||||||
OSStatus err, result = eventNotHandledErr;
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
WindowRef window = (WindowRef) inUserData;
|
// WindowRef window = (WindowRef) inUserData;
|
||||||
|
//
|
||||||
switch (GetEventClass(inEvent))
|
// switch (GetEventClass(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventClassWindow:
|
// case kEventClassWindow:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventWindowClose:
|
// case kEventWindowClose:
|
||||||
QuitAppModalLoopForWindow(window);
|
// QuitAppModalLoopForWindow(window);
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventClassCommand:
|
// case kEventClassCommand:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
HICommandExtended tHICommand;
|
// HICommandExtended tHICommand;
|
||||||
|
//
|
||||||
case kEventCommandUpdateStatus:
|
// case kEventCommandUpdateStatus:
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand);
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand);
|
||||||
if (err == noErr && tHICommand.commandID == 'clos')
|
// if (err == noErr && tHICommand.commandID == 'clos')
|
||||||
{
|
// {
|
||||||
UpdateMenuCommandStatus(true);
|
// UpdateMenuCommandStatus(true);
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventCommandProcess:
|
// case kEventCommandProcess:
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand);
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &tHICommand);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
err = MPWaitOnSemaphore(cisem, kDurationForever);
|
// err = MPWaitOnSemaphore(cisem, kDurationForever);
|
||||||
|
//
|
||||||
if (tHICommand.commandID == 'rSET')
|
// if (tHICommand.commandID == 'rSET')
|
||||||
{
|
// {
|
||||||
[ciFilter setDefaults];
|
// [ciFilter setDefaults];
|
||||||
FilterToFilterParam();
|
// FilterToFilterParam();
|
||||||
FilterUISetValues(ciFilterUIPane);
|
// FilterUISetValues(ciFilterUIPane);
|
||||||
|
//
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
unsigned long i = tHICommand.commandID & 0x00FFFFFF;
|
// unsigned long i = tHICommand.commandID & 0x00FFFFFF;
|
||||||
|
//
|
||||||
switch (tHICommand.commandID & 0xFF000000)
|
// switch (tHICommand.commandID & 0xFF000000)
|
||||||
{
|
// {
|
||||||
case kCommandFilterMenuBase:
|
// case kCommandFilterMenuBase:
|
||||||
DeinitCoreImageFilter();
|
// DeinitCoreImageFilter();
|
||||||
|
//
|
||||||
CFRelease(ciFilterName);
|
// CFRelease(ciFilterName);
|
||||||
ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef) [ciFilterNameList objectAtIndex: i]);
|
// ciFilterName = CFStringCreateCopy(kCFAllocatorDefault, (CFStringRef) [ciFilterNameList objectAtIndex: i]);
|
||||||
|
//
|
||||||
InitCoreImageFilter();
|
// InitCoreImageFilter();
|
||||||
|
//
|
||||||
ReplaceFilterUI(window);
|
// ReplaceFilterUI(window);
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kCommandCheckBoxBase:
|
// case kCommandCheckBoxBase:
|
||||||
ciFilterParam[i].u.b.cur = !(ciFilterParam[i].u.b.cur);
|
// ciFilterParam[i].u.b.cur = !(ciFilterParam[i].u.b.cur);
|
||||||
FilterParamToFilter();
|
// FilterParamToFilter();
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kCommandSliderBase:
|
// case kCommandSliderBase:
|
||||||
SInt32 value;
|
// SInt32 value;
|
||||||
|
//
|
||||||
value = HIViewGetValue(tHICommand.source.control);
|
// value = HIViewGetValue(tHICommand.source.control);
|
||||||
ciFilterParam[i].u.s.cur = ciFilterParam[i].u.s.min + (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) value / (float) FIXEDRANGE;
|
// ciFilterParam[i].u.s.cur = ciFilterParam[i].u.s.min + (ciFilterParam[i].u.s.max - ciFilterParam[i].u.s.min) * (float) value / (float) FIXEDRANGE;
|
||||||
FilterParamToFilter();
|
// FilterParamToFilter();
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kCommandColorButtonBase:
|
// case kCommandColorButtonBase:
|
||||||
NColorPickerInfo info;
|
// NColorPickerInfo info;
|
||||||
|
//
|
||||||
memset(&info, 0, sizeof(NColorPickerInfo));
|
// memset(&info, 0, sizeof(NColorPickerInfo));
|
||||||
info.placeWhere = kCenterOnMainScreen;
|
// info.placeWhere = kCenterOnMainScreen;
|
||||||
info.flags = kColorPickerDialogIsMoveable | kColorPickerDialogIsModal;
|
// info.flags = kColorPickerDialogIsMoveable | kColorPickerDialogIsModal;
|
||||||
info.theColor.color.rgb.red = (int) (65535.0 * ciFilterParam[i].u.c.r);
|
// info.theColor.color.rgb.red = (int) (65535.0 * ciFilterParam[i].u.c.r);
|
||||||
info.theColor.color.rgb.green = (int) (65535.0 * ciFilterParam[i].u.c.g);
|
// info.theColor.color.rgb.green = (int) (65535.0 * ciFilterParam[i].u.c.g);
|
||||||
info.theColor.color.rgb.blue = (int) (65535.0 * ciFilterParam[i].u.c.b);
|
// info.theColor.color.rgb.blue = (int) (65535.0 * ciFilterParam[i].u.c.b);
|
||||||
|
//
|
||||||
err = NPickColor(&info);
|
// err = NPickColor(&info);
|
||||||
|
//
|
||||||
if ((err == noErr) && info.newColorChosen)
|
// if ((err == noErr) && info.newColorChosen)
|
||||||
{
|
// {
|
||||||
ciFilterParam[i].u.c.r = (float) info.theColor.color.rgb.red / 65535.0f;
|
// ciFilterParam[i].u.c.r = (float) info.theColor.color.rgb.red / 65535.0f;
|
||||||
ciFilterParam[i].u.c.g = (float) info.theColor.color.rgb.green / 65535.0f;
|
// ciFilterParam[i].u.c.g = (float) info.theColor.color.rgb.green / 65535.0f;
|
||||||
ciFilterParam[i].u.c.b = (float) info.theColor.color.rgb.blue / 65535.0f;
|
// ciFilterParam[i].u.c.b = (float) info.theColor.color.rgb.blue / 65535.0f;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
FilterParamToFilter();
|
// FilterParamToFilter();
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
err = MPSignalSemaphore(cisem);
|
// err = MPSignalSemaphore(cisem);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return (result);
|
// return (result);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitCoreImageContext (CGLContextObj cglctx, CGLPixelFormatObj cglpix)
|
void InitCoreImageContext (CGLContextObj cglctx, CGLPixelFormatObj cglpix)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
@autoreleasepool
|
||||||
|
{
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
FilterToFilterParam();
|
FilterToFilterParam();
|
||||||
|
|
||||||
cgColor = CGColorSpaceCreateDeviceRGB();
|
cgColor = CGColorSpaceCreateDeviceRGB();
|
||||||
|
|
||||||
#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT
|
#ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT
|
||||||
ciContext = [[CIContext contextWithCGLContext: cglctx pixelFormat: cglpix options: NULL] retain];
|
ciContext = [[CIContext contextWithCGLContext: cglctx pixelFormat: cglpix options: NULL] retain];
|
||||||
#else
|
#else
|
||||||
ciContext = [[CIContext contextWithCGLContext: cglctx pixelFormat: cglpix colorSpace: cgColor options: NULL] retain];
|
ciContext = [CIContext contextWithCGLContext: cglctx pixelFormat: cglpix colorSpace: cgColor options: NULL];
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeinitCoreImageContext (void)
|
void DeinitCoreImageContext (void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
ciContext = nil;
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
[ciContext release];
|
|
||||||
CGColorSpaceRelease(cgColor);
|
CGColorSpaceRelease(cgColor);
|
||||||
|
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawWithCoreImageFilter (CGRect src, CGImageRef img)
|
void DrawWithCoreImageFilter (CGRect src, CGImageRef img)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
@autoreleasepool
|
||||||
NSAutoreleasePool *pool;
|
{
|
||||||
|
dispatch_semaphore_wait(cisem, DISPATCH_TIME_FOREVER);
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
err = MPWaitOnSemaphore(cisem, kDurationForever);
|
|
||||||
|
|
||||||
if (ciFilterHasInputImage)
|
if (ciFilterHasInputImage)
|
||||||
{
|
{
|
||||||
|
@ -840,7 +810,6 @@ void DrawWithCoreImageFilter (CGRect src, CGImageRef img)
|
||||||
|
|
||||||
[ciContext drawImage: [ciFilter valueForKey: @"outputImage"] atPoint: CGPointZero fromRect: src];
|
[ciContext drawImage: [ciFilter valueForKey: @"outputImage"] atPoint: CGPointZero fromRect: src];
|
||||||
|
|
||||||
err = MPSignalSemaphore(cisem);
|
dispatch_semaphore_signal(cisem);
|
||||||
|
}
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ enum
|
||||||
{
|
{
|
||||||
kS9xMacAlertFolderNotFound = 1,
|
kS9xMacAlertFolderNotFound = 1,
|
||||||
kS9xMacAlertFolderNotFoundHint,
|
kS9xMacAlertFolderNotFoundHint,
|
||||||
kS9xMacAlertFolderFailToCreate,
|
kS9xMacAlertFolderNotWritable,
|
||||||
kS9xMacAlertFolderFailToCreateHint,
|
kS9xMacAlertFolderNotWritableHint,
|
||||||
kS9xMacAlertkBadRom,
|
kS9xMacAlertkBadRom,
|
||||||
kS9xMacAlertkBadRomHint,
|
kS9xMacAlertkBadRomHint,
|
||||||
kS9xMacAlertCFCantAddEntry,
|
kS9xMacAlertCFCantAddEntry,
|
||||||
|
|
|
@ -253,7 +253,7 @@ void AppearanceAlert (AlertType type, int stringID1, int stringID2)
|
||||||
if (key1) mes1 = CFCopyLocalizedString(key1, "mes1"); else mes1 = NULL;
|
if (key1) mes1 = CFCopyLocalizedString(key1, "mes1"); else mes1 = NULL;
|
||||||
if (key2) mes2 = CFCopyLocalizedString(key2, "mes2"); else mes2 = NULL;
|
if (key2) mes2 = CFCopyLocalizedString(key2, "mes2"); else mes2 = NULL;
|
||||||
|
|
||||||
PlayAlertSound();
|
NSBeep();
|
||||||
|
|
||||||
err = CreateStandardAlert(type, mes1, mes2, NULL, &dialog);
|
err = CreateStandardAlert(type, mes1, mes2, NULL, &dialog);
|
||||||
err = RunStandardAlert(dialog, NULL, &outItemHit);
|
err = RunStandardAlert(dialog, NULL, &outItemHit);
|
|
@ -1,619 +0,0 @@
|
||||||
/*****************************************************************************\
|
|
||||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
||||||
This file is licensed under the Snes9x License.
|
|
||||||
For further information, consult the LICENSE file in the root directory.
|
|
||||||
\*****************************************************************************/
|
|
||||||
|
|
||||||
/***********************************************************************************
|
|
||||||
SNES9X for Mac OS (c) Copyright John Stiles
|
|
||||||
|
|
||||||
Snes9x for Mac OS X
|
|
||||||
|
|
||||||
(c) Copyright 2001 - 2011 zones
|
|
||||||
(c) Copyright 2002 - 2005 107
|
|
||||||
(c) Copyright 2002 PB1400c
|
|
||||||
(c) Copyright 2004 Alexander and Sander
|
|
||||||
(c) Copyright 2004 - 2005 Steven Seeger
|
|
||||||
(c) Copyright 2005 Ryan Vogt
|
|
||||||
***********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "snes9x.h"
|
|
||||||
#include "memmap.h"
|
|
||||||
#include "movie.h"
|
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include "mac-prefix.h"
|
|
||||||
#include "mac-dialog.h"
|
|
||||||
#include "mac-os.h"
|
|
||||||
#include "mac-stringtools.h"
|
|
||||||
#include "mac-file.h"
|
|
||||||
|
|
||||||
static void AddFolderIcon (FSRef *, const char *);
|
|
||||||
static OSStatus FindSNESFolder (FSRef *, char *, const char *);
|
|
||||||
static OSStatus FindApplicationSupportFolder (FSRef *, char *, const char *);
|
|
||||||
static OSStatus FindCustomFolder (FSRef *, char *, const char *);
|
|
||||||
|
|
||||||
|
|
||||||
void CheckSaveFolder (FSRef *cartRef)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
Boolean r;
|
|
||||||
FSCatalogInfo finfo;
|
|
||||||
FSVolumeInfo vinfo;
|
|
||||||
FSRef ref;
|
|
||||||
CFURLRef burl, purl;
|
|
||||||
char s[PATH_MAX + 1];
|
|
||||||
|
|
||||||
switch (saveInROMFolder)
|
|
||||||
{
|
|
||||||
case 0: // Snes9x folder
|
|
||||||
burl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
|
||||||
purl = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, burl);
|
|
||||||
r = CFURLGetFSRef(purl, &ref);
|
|
||||||
CFRelease(purl);
|
|
||||||
CFRelease(burl);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // ROM folder
|
|
||||||
err = FSGetCatalogInfo(cartRef, kFSCatInfoNone, NULL, NULL, NULL, &ref);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // Application Support folder
|
|
||||||
return;
|
|
||||||
|
|
||||||
case 4: // Custom folder
|
|
||||||
if (saveFolderPath == NULL)
|
|
||||||
{
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = CFStringGetCString(saveFolderPath, s, PATH_MAX, kCFStringEncodingUTF8);
|
|
||||||
err = FSPathMakeRef((unsigned char *) s, &ref, NULL);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderNotFound, kS9xMacAlertFolderNotFoundHint);
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = FSGetCatalogInfo(&ref, kFSCatInfoUserPrivs | kFSCatInfoVolume, &finfo, NULL, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
if (finfo.userPrivileges & kioACUserNoMakeChangesMask)
|
|
||||||
{
|
|
||||||
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderFailToCreate, kS9xMacAlertFolderFailToCreateHint);
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = FSGetVolumeInfo(finfo.volume, 0, NULL, kFSVolInfoFlags, &vinfo, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
if ((vinfo.flags & kFSVolFlagHardwareLockedMask) || (vinfo.flags & kFSVolFlagSoftwareLockedMask))
|
|
||||||
{
|
|
||||||
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderFailToCreate, kS9xMacAlertFolderFailToCreateHint);
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus FindSNESFolder (FSRef *folderRef, char *folderPath, const char *folderName)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
CFURLRef burl, purl;
|
|
||||||
CFStringRef fstr;
|
|
||||||
FSRef pref;
|
|
||||||
UniChar buffer[PATH_MAX + 1];
|
|
||||||
Boolean r;
|
|
||||||
|
|
||||||
fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding());
|
|
||||||
CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer);
|
|
||||||
|
|
||||||
burl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
|
||||||
purl = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, burl);
|
|
||||||
r = CFURLGetFSRef(purl, &pref);
|
|
||||||
|
|
||||||
err = FSMakeFSRefUnicode(&pref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef);
|
|
||||||
if (err == dirNFErr || err == fnfErr)
|
|
||||||
{
|
|
||||||
err = FSCreateDirectoryUnicode(&pref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, NULL, folderRef, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
AddFolderIcon(folderRef, folderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == noErr)
|
|
||||||
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
|
|
||||||
|
|
||||||
CFRelease(purl);
|
|
||||||
CFRelease(burl);
|
|
||||||
CFRelease(fstr);
|
|
||||||
|
|
||||||
return (err);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus FindApplicationSupportFolder (FSRef *folderRef, char *folderPath, const char *folderName)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
FSRef p2ref, p1ref;
|
|
||||||
CFStringRef fstr;
|
|
||||||
UniChar buffer[PATH_MAX + 1];
|
|
||||||
UniChar s9xfolder[6] = { 'S', 'n', 'e', 's', '9', 'x' },
|
|
||||||
oldfolder[6] = { 'S', 'N', 'E', 'S', '9', 'X' };
|
|
||||||
|
|
||||||
err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &p2ref);
|
|
||||||
if (err)
|
|
||||||
return (err);
|
|
||||||
|
|
||||||
err = FSMakeFSRefUnicode(&p2ref, 6, s9xfolder, kTextEncodingUnicodeDefault, &p1ref);
|
|
||||||
if (err == dirNFErr || err == fnfErr)
|
|
||||||
{
|
|
||||||
err = FSMakeFSRefUnicode(&p2ref, 6, oldfolder, kTextEncodingUnicodeDefault, &p1ref);
|
|
||||||
if (err == dirNFErr || err == fnfErr)
|
|
||||||
err = FSCreateDirectoryUnicode(&p2ref, 6, s9xfolder, kFSCatInfoNone, NULL, &p1ref, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
return (err);
|
|
||||||
|
|
||||||
fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding());
|
|
||||||
CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer);
|
|
||||||
|
|
||||||
err = FSMakeFSRefUnicode(&p1ref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef);
|
|
||||||
if (err == dirNFErr || err == fnfErr)
|
|
||||||
{
|
|
||||||
err = FSCreateDirectoryUnicode(&p1ref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, NULL, folderRef, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
AddFolderIcon(folderRef, folderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == noErr)
|
|
||||||
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
|
|
||||||
|
|
||||||
CFRelease(fstr);
|
|
||||||
|
|
||||||
return (err);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus FindCustomFolder (FSRef *folderRef, char *folderPath, const char *folderName)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
CFStringRef fstr;
|
|
||||||
FSRef pref;
|
|
||||||
UniChar buffer[PATH_MAX + 1];
|
|
||||||
char s[PATH_MAX + 1];
|
|
||||||
|
|
||||||
if (saveFolderPath == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
err = CFStringGetCString(saveFolderPath, s, PATH_MAX, kCFStringEncodingUTF8) ? noErr : -1;
|
|
||||||
if (err == noErr)
|
|
||||||
err = FSPathMakeRef((unsigned char *) s, &pref, NULL);
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
return (err);
|
|
||||||
|
|
||||||
fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding());
|
|
||||||
CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer);
|
|
||||||
|
|
||||||
err = FSMakeFSRefUnicode(&pref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef);
|
|
||||||
if (err == dirNFErr || err == fnfErr)
|
|
||||||
{
|
|
||||||
err = FSCreateDirectoryUnicode(&pref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, NULL, folderRef, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
AddFolderIcon(folderRef, folderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == noErr)
|
|
||||||
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
|
|
||||||
|
|
||||||
CFRelease(fstr);
|
|
||||||
|
|
||||||
return (err);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChangeTypeAndCreator (const char *path, OSType type, OSType creator)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
FSRef ref;
|
|
||||||
|
|
||||||
err = FSPathMakeRef((unsigned char *) path, &ref, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
FSCatalogInfo catinfo;
|
|
||||||
|
|
||||||
err = FSGetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catinfo, NULL, NULL, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
((FileInfo *) &catinfo.finderInfo)->fileCreator = creator;
|
|
||||||
((FileInfo *) &catinfo.finderInfo)->fileType = type;
|
|
||||||
|
|
||||||
err = FSSetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catinfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddFolderIcon (FSRef *fref, const char *folderName)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
FSCatalogInfo fcat, icat;
|
|
||||||
FSRef bref, iref;
|
|
||||||
CFStringRef str;
|
|
||||||
CFURLRef url;
|
|
||||||
IconFamilyHandle family;
|
|
||||||
IconRef icon;
|
|
||||||
HFSUniStr255 fork;
|
|
||||||
Boolean r;
|
|
||||||
SInt16 resf;
|
|
||||||
char name[64];
|
|
||||||
UniChar iconName[5] = { 'I', 'c', 'o', 'n', '\r' };
|
|
||||||
|
|
||||||
strcpy(name, "folder_");
|
|
||||||
strcat(name, folderName);
|
|
||||||
|
|
||||||
str = CFStringCreateWithCString(kCFAllocatorDefault, name, CFStringGetSystemEncoding());
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), str, CFSTR("icns"), NULL);
|
|
||||||
if (url)
|
|
||||||
{
|
|
||||||
r = CFURLGetFSRef(url, &bref);
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
err = RegisterIconRefFromFSRef('~9X~', 'TEMP', &bref, &icon);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = FSGetResourceForkName(&fork);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = FSCreateResourceFile(fref, 5, iconName, kFSCatInfoNone, NULL, fork.length, fork.unicode, &iref, NULL);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = FSOpenResourceFile(&iref, fork.length, fork.unicode, fsWrPerm, &resf);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = IconRefToIconFamily(icon, kSelectorAllAvailableData, &family);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
AddResource((Handle) family, 'icns', -16455, "\p");
|
|
||||||
WriteResource((Handle) family);
|
|
||||||
ReleaseResource((Handle) family);
|
|
||||||
|
|
||||||
err = FSGetCatalogInfo(&iref, kFSCatInfoFinderInfo, &icat, NULL, NULL, NULL);
|
|
||||||
((FileInfo *) &icat.finderInfo)->finderFlags |= kIsInvisible;
|
|
||||||
((FileInfo *) &icat.finderInfo)->fileCreator = 'MACS';
|
|
||||||
((FileInfo *) &icat.finderInfo)->fileType = 'icon';
|
|
||||||
err = FSSetCatalogInfo(&iref, kFSCatInfoFinderInfo, &icat);
|
|
||||||
|
|
||||||
err = FSGetCatalogInfo(fref, kFSCatInfoFinderInfo, &fcat, NULL, NULL, NULL);
|
|
||||||
((FolderInfo *) &fcat.finderInfo)->finderFlags |= kHasCustomIcon;
|
|
||||||
((FolderInfo *) &fcat.finderInfo)->finderFlags &= ~kHasBeenInited;
|
|
||||||
err = FSSetCatalogInfo(fref, kFSCatInfoFinderInfo, &fcat);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseResFile(resf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = UnregisterIconRef('~9X~', 'TEMP');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetFilename (const char *inExt, enum s9x_getdirtype dirtype)
|
|
||||||
{
|
|
||||||
static int index = 0;
|
|
||||||
static char filePath[4][PATH_MAX + 1];
|
|
||||||
|
|
||||||
OSStatus err;
|
|
||||||
FSRef ref;
|
|
||||||
uint32 type;
|
|
||||||
char folderName[16];
|
|
||||||
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
index++;
|
|
||||||
if (index > 3)
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
folderName[0] = filePath[index][0] = 0;
|
|
||||||
|
|
||||||
if (strlen(inExt) < 4)
|
|
||||||
return (filePath[index]);
|
|
||||||
|
|
||||||
p = inExt + strlen(inExt) - 4;
|
|
||||||
type = ((uint32) p[0] << 24) + ((uint32) p[1] << 16) + ((uint32) p[2] << 8) + (uint32) p[3];
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case '.srm':
|
|
||||||
case '.rtc':
|
|
||||||
strcpy(folderName, "SRAMs");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.frz':
|
|
||||||
strcpy(folderName, "Freezes");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.spc':
|
|
||||||
strcpy(folderName, "SPCs");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.cht':
|
|
||||||
strcpy(folderName, "Cheats");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.ups':
|
|
||||||
case '.ips':
|
|
||||||
strcpy(folderName, "Patches");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.png':
|
|
||||||
strcpy(folderName, "Screenshots");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.dat':
|
|
||||||
case '.out':
|
|
||||||
case '.log':
|
|
||||||
strcpy(folderName, "Logs");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '.bio': // dummy
|
|
||||||
strcpy(folderName, "BIOSes");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folderName[0] && (saveInROMFolder != 1))
|
|
||||||
{
|
|
||||||
char s[PATH_MAX + 1];
|
|
||||||
|
|
||||||
s[0] = 0;
|
|
||||||
err = -1;
|
|
||||||
|
|
||||||
if (saveInROMFolder == 0)
|
|
||||||
{
|
|
||||||
err = FindSNESFolder(&ref, s, folderName);
|
|
||||||
if (err)
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveInROMFolder == 4)
|
|
||||||
{
|
|
||||||
err = FindCustomFolder(&ref, s, folderName);
|
|
||||||
if (err)
|
|
||||||
saveInROMFolder = 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveInROMFolder == 2)
|
|
||||||
err = FindApplicationSupportFolder(&ref, s, folderName);
|
|
||||||
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
|
||||||
snprintf(filePath[index], PATH_MAX + 1, "%s%s%s%s", s, MAC_PATH_SEPARATOR, fname, inExt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
|
||||||
_makepath(filePath[index], drive, dir, fname, inExt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
|
||||||
_makepath(filePath[index], drive, dir, fname, inExt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (filePath[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetSPCFilename (void)
|
|
||||||
{
|
|
||||||
char spcExt[16];
|
|
||||||
|
|
||||||
sprintf(spcExt, ".%03d.spc", (int) spcFileCount);
|
|
||||||
|
|
||||||
spcFileCount++;
|
|
||||||
if (spcFileCount == 1000)
|
|
||||||
spcFileCount = 0;
|
|
||||||
|
|
||||||
return (S9xGetFilename(spcExt, SPC_DIR));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetPNGFilename (void)
|
|
||||||
{
|
|
||||||
char pngExt[16];
|
|
||||||
|
|
||||||
sprintf(pngExt, ".%03d.png", (int) pngFileCount);
|
|
||||||
|
|
||||||
pngFileCount++;
|
|
||||||
if (pngFileCount == 1000)
|
|
||||||
pngFileCount = 0;
|
|
||||||
|
|
||||||
return (S9xGetFilename(pngExt, SCREENSHOT_DIR));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetFreezeFilename (int which)
|
|
||||||
{
|
|
||||||
char frzExt[16];
|
|
||||||
|
|
||||||
sprintf(frzExt, ".%03d.frz", which);
|
|
||||||
|
|
||||||
return (S9xGetFilename(frzExt, SNAPSHOT_DIR));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetFilenameInc (const char *inExt, enum s9x_getdirtype dirtype)
|
|
||||||
{
|
|
||||||
uint32 type;
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
if (strlen(inExt) < 4)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
p = inExt + strlen(inExt) - 4;
|
|
||||||
type = ((uint32) p[0] << 24) + ((uint32) p[1] << 16) + ((uint32) p[2] << 8) + (uint32) p[3];
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case '.spc':
|
|
||||||
return (S9xGetSPCFilename());
|
|
||||||
|
|
||||||
case '.png':
|
|
||||||
return (S9xGetPNGFilename());
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xChooseFilename (bool8 read_only)
|
|
||||||
{
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xChooseMovieFilename (bool8 read_only)
|
|
||||||
{
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 S9xOpenSnapshotFile (const char *fname, bool8 read_only, STREAM *file)
|
|
||||||
{
|
|
||||||
if (read_only)
|
|
||||||
{
|
|
||||||
if (0 != (*file = OPEN_STREAM(fname, "rb")))
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (0 != (*file = OPEN_STREAM(fname, "wb")))
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void S9xCloseSnapshotFile (STREAM file)
|
|
||||||
{
|
|
||||||
CLOSE_STREAM(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xBasename (const char *in)
|
|
||||||
{
|
|
||||||
static char s[PATH_MAX + 1];
|
|
||||||
|
|
||||||
strncpy(s, in, PATH_MAX + 1);
|
|
||||||
s[PATH_MAX] = 0;
|
|
||||||
|
|
||||||
size_t l = strlen(s);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < l; i++)
|
|
||||||
{
|
|
||||||
if (s[i] < 32 || s[i] >= 127)
|
|
||||||
s[i] = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
return (basename(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * S9xGetDirectory (enum s9x_getdirtype dirtype)
|
|
||||||
{
|
|
||||||
static int index = 0;
|
|
||||||
static char path[4][PATH_MAX + 1];
|
|
||||||
|
|
||||||
char inExt[16];
|
|
||||||
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
|
|
||||||
|
|
||||||
index++;
|
|
||||||
if (index > 3)
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
switch (dirtype)
|
|
||||||
{
|
|
||||||
case SNAPSHOT_DIR: strcpy(inExt, ".frz"); break;
|
|
||||||
case SRAM_DIR: strcpy(inExt, ".srm"); break;
|
|
||||||
case SCREENSHOT_DIR: strcpy(inExt, ".png"); break;
|
|
||||||
case SPC_DIR: strcpy(inExt, ".spc"); break;
|
|
||||||
case CHEAT_DIR: strcpy(inExt, ".cht"); break;
|
|
||||||
case BIOS_DIR: strcpy(inExt, ".bio"); break;
|
|
||||||
case LOG_DIR: strcpy(inExt, ".log"); break;
|
|
||||||
default: strcpy(inExt, ".xxx"); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_splitpath(S9xGetFilename(inExt, dirtype), drive, dir, fname, ext);
|
|
||||||
_makepath(path[index], drive, dir, "", "");
|
|
||||||
|
|
||||||
int l = strlen(path[index]);
|
|
||||||
if (l > 1)
|
|
||||||
path[index][l - 1] = 0;
|
|
||||||
|
|
||||||
return (path[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
|
|
||||||
{
|
|
||||||
drive[0] = 0;
|
|
||||||
fname[0] = 0;
|
|
||||||
ext[0] = 0;
|
|
||||||
dir[0] = 0;
|
|
||||||
|
|
||||||
int x;
|
|
||||||
|
|
||||||
x = strlen(path) - 1;
|
|
||||||
if (x < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (x && (path[x] != MAC_PATH_SEP_CHAR))
|
|
||||||
x--;
|
|
||||||
|
|
||||||
if (x)
|
|
||||||
{
|
|
||||||
strcpy(dir, path);
|
|
||||||
dir[x + 1] = 0;
|
|
||||||
|
|
||||||
strcpy(fname, path + x + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
strcpy(fname, path);
|
|
||||||
|
|
||||||
x = strlen(fname);
|
|
||||||
while (x && (fname[x] != '.'))
|
|
||||||
x--;
|
|
||||||
|
|
||||||
if (x)
|
|
||||||
{
|
|
||||||
strcpy(ext, fname + x);
|
|
||||||
fname[x] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _makepath (char *path, const char *drive, const char *dir, const char *fname, const char *ext)
|
|
||||||
{
|
|
||||||
static const char emp[] = "", dot[] = ".";
|
|
||||||
|
|
||||||
const char *d, *f, *e, *p;
|
|
||||||
|
|
||||||
d = dir ? dir : emp;
|
|
||||||
f = fname ? fname : emp;
|
|
||||||
e = ext ? ext : emp;
|
|
||||||
p = (e[0] && e[0] != '.') ? dot : emp;
|
|
||||||
|
|
||||||
snprintf(path, PATH_MAX + 1, "%s%s%s%s", d, f, p, e);
|
|
||||||
}
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef _mac_file_h_
|
#ifndef _mac_file_h_
|
||||||
#define _mac_file_h_
|
#define _mac_file_h_
|
||||||
|
|
||||||
void CheckSaveFolder (FSRef *);
|
void CheckSaveFolder (NSURL *);
|
||||||
void ChangeTypeAndCreator (const char *, OSType, OSType);
|
void ChangeTypeAndCreator (const char *, OSType, OSType);
|
||||||
const char * S9xGetSPCFilename (void);
|
const char * S9xGetSPCFilename (void);
|
||||||
const char * S9xGetPNGFilename (void);
|
const char * S9xGetPNGFilename (void);
|
||||||
|
|
|
@ -0,0 +1,504 @@
|
||||||
|
/*****************************************************************************\
|
||||||
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||||
|
This file is licensed under the Snes9x License.
|
||||||
|
For further information, consult the LICENSE file in the root directory.
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************************
|
||||||
|
SNES9X for Mac OS (c) Copyright John Stiles
|
||||||
|
|
||||||
|
Snes9x for Mac OS X
|
||||||
|
|
||||||
|
(c) Copyright 2001 - 2011 zones
|
||||||
|
(c) Copyright 2002 - 2005 107
|
||||||
|
(c) Copyright 2002 PB1400c
|
||||||
|
(c) Copyright 2004 Alexander and Sander
|
||||||
|
(c) Copyright 2004 - 2005 Steven Seeger
|
||||||
|
(c) Copyright 2005 Ryan Vogt
|
||||||
|
***********************************************************************************/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include "snes9x.h"
|
||||||
|
#include "memmap.h"
|
||||||
|
#include "movie.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
|
#include "mac-prefix.h"
|
||||||
|
#include "mac-dialog.h"
|
||||||
|
#include "mac-os.h"
|
||||||
|
#include "mac-stringtools.h"
|
||||||
|
#include "mac-file.h"
|
||||||
|
|
||||||
|
static void AddFolderIcon (NSURL *, const char *);
|
||||||
|
static NSURL *FindSNESFolder (const char *);
|
||||||
|
static NSURL *FindApplicationSupportFolder (NSURL *, const char *);
|
||||||
|
static NSURL *FindCustomFolder (NSURL *, const char *);
|
||||||
|
|
||||||
|
|
||||||
|
void CheckSaveFolder (NSURL *cartURL)
|
||||||
|
{
|
||||||
|
NSString *folderPath = nil;
|
||||||
|
|
||||||
|
switch (saveInROMFolder)
|
||||||
|
{
|
||||||
|
case 1: // ROM folder
|
||||||
|
folderPath = cartURL.URLByDeletingLastPathComponent.path;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // Application Support folder
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 4: // Custom folder
|
||||||
|
if (saveFolderPath == NULL)
|
||||||
|
{
|
||||||
|
saveInROMFolder = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL isDirectory = NO;
|
||||||
|
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:saveFolderPath isDirectory:&isDirectory];
|
||||||
|
|
||||||
|
if (exists && isDirectory)
|
||||||
|
{
|
||||||
|
folderPath = saveFolderPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderNotFound, kS9xMacAlertFolderNotFoundHint);
|
||||||
|
saveInROMFolder = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL writable = [[NSFileManager defaultManager] isWritableFileAtPath:folderPath];
|
||||||
|
|
||||||
|
if (!writable)
|
||||||
|
{
|
||||||
|
//AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderNotWritable, kS9xMacAlertFolderNotWritableHint);
|
||||||
|
saveInROMFolder = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSURL *FindSNESFolder (const char *folderName)
|
||||||
|
{
|
||||||
|
NSURL *purl = nil;
|
||||||
|
NSString *fstr = [NSString stringWithUTF8String:folderName];
|
||||||
|
|
||||||
|
purl = [[[NSBundle mainBundle] bundleURL].URLByDeletingLastPathComponent URLByAppendingPathComponent:fstr];
|
||||||
|
|
||||||
|
if (![NSFileManager.defaultManager fileExistsAtPath:purl.path])
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
if ( [NSFileManager.defaultManager createDirectoryAtURL:purl withIntermediateDirectories:YES attributes:nil error:&error] )
|
||||||
|
{
|
||||||
|
AddFolderIcon(purl, folderName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[NSAlert alertWithError:error] runModal];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return purl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSURL *FindApplicationSupportFolder (const char *folderName)
|
||||||
|
{
|
||||||
|
NSURL *purl = nil;
|
||||||
|
NSURL *baseURL = nil;
|
||||||
|
NSURL *s9xURL = nil;
|
||||||
|
NSURL *oldURL = nil;
|
||||||
|
NSString *fstr = [NSString stringWithUTF8String:folderName];
|
||||||
|
|
||||||
|
baseURL = [[NSFileManager.defaultManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask].firstObject URLByAppendingPathComponent:fstr];
|
||||||
|
|
||||||
|
if (!baseURL)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
s9xURL = [baseURL URLByAppendingPathComponent:@"Snes9x"];
|
||||||
|
oldURL = [baseURL URLByAppendingPathComponent:@"SNES9X"];
|
||||||
|
|
||||||
|
if ([NSFileManager.defaultManager fileExistsAtPath:s9xURL.path])
|
||||||
|
{
|
||||||
|
purl = s9xURL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ([NSFileManager.defaultManager fileExistsAtPath:oldURL.path])
|
||||||
|
{
|
||||||
|
purl = oldURL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
if ([NSFileManager.defaultManager createDirectoryAtURL:s9xURL withIntermediateDirectories:YES attributes:nil error:&error])
|
||||||
|
{
|
||||||
|
purl = s9xURL;
|
||||||
|
AddFolderIcon(purl, folderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return purl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSURL *FindCustomFolder (const char *folderName)
|
||||||
|
{
|
||||||
|
NSURL *purl = nil;
|
||||||
|
|
||||||
|
if (saveFolderPath == NULL)
|
||||||
|
return nil;
|
||||||
|
|
||||||
|
purl = [NSURL fileURLWithPath:saveFolderPath];
|
||||||
|
|
||||||
|
if (![NSFileManager.defaultManager fileExistsAtPath:saveFolderPath])
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
if (![NSFileManager.defaultManager createDirectoryAtPath:saveFolderPath withIntermediateDirectories:YES attributes:nil error:&error])
|
||||||
|
{
|
||||||
|
[[NSAlert alertWithError:error] runModal];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
purl = [purl URLByAppendingPathComponent:[NSString stringWithUTF8String:folderName]];
|
||||||
|
|
||||||
|
if (![NSFileManager.defaultManager fileExistsAtPath:purl.path])
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
if ([NSFileManager.defaultManager createDirectoryAtPath:saveFolderPath withIntermediateDirectories:YES attributes:nil error:&error])
|
||||||
|
{
|
||||||
|
AddFolderIcon(purl, folderName);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
[[NSAlert alertWithError:error] runModal];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return purl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeTypeAndCreator (const char *path, OSType type, OSType creator)
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
if (![NSFileManager.defaultManager setAttributes:@{NSFileHFSCreatorCode: @(creator), NSFileHFSTypeCode: @(type)} ofItemAtPath:[NSString stringWithUTF8String:path] error:&error])
|
||||||
|
{
|
||||||
|
[[NSAlert alertWithError:error] runModal];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AddFolderIcon (NSURL *fref, const char *folderName)
|
||||||
|
{
|
||||||
|
NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.snes9x.macos.snes9x-framework"];
|
||||||
|
NSString *filename = [@"folder_" stringByAppendingString:[NSString stringWithUTF8String:folderName]];
|
||||||
|
NSURL *imageURL = [bundle URLForResource:filename withExtension:@"icns"];
|
||||||
|
NSImage *image = [[NSImage alloc] initWithContentsOfURL:imageURL];
|
||||||
|
|
||||||
|
if ( image != nil )
|
||||||
|
{
|
||||||
|
[NSWorkspace.sharedWorkspace setIcon:image forFile:fref.path options:0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetFilename (const char *inExt, enum s9x_getdirtype dirtype)
|
||||||
|
{
|
||||||
|
static int index = 0;
|
||||||
|
static char filePath[4][PATH_MAX + 1];
|
||||||
|
|
||||||
|
uint32 type;
|
||||||
|
char folderName[16];
|
||||||
|
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (index > 3)
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
folderName[0] = filePath[index][0] = 0;
|
||||||
|
|
||||||
|
if (strlen(inExt) < 4)
|
||||||
|
return (filePath[index]);
|
||||||
|
|
||||||
|
p = inExt + strlen(inExt) - 4;
|
||||||
|
type = ((uint32) p[0] << 24) + ((uint32) p[1] << 16) + ((uint32) p[2] << 8) + (uint32) p[3];
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case '.srm':
|
||||||
|
case '.rtc':
|
||||||
|
strcpy(folderName, "SRAMs");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.frz':
|
||||||
|
strcpy(folderName, "Freezes");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.spc':
|
||||||
|
strcpy(folderName, "SPCs");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.cht':
|
||||||
|
strcpy(folderName, "Cheats");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.ups':
|
||||||
|
case '.ips':
|
||||||
|
strcpy(folderName, "Patches");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.png':
|
||||||
|
strcpy(folderName, "Screenshots");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.dat':
|
||||||
|
case '.out':
|
||||||
|
case '.log':
|
||||||
|
strcpy(folderName, "Logs");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '.bio': // dummy
|
||||||
|
strcpy(folderName, "BIOSes");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folderName[0] && (saveInROMFolder != 1))
|
||||||
|
{
|
||||||
|
NSURL *folderURL = nil;
|
||||||
|
if (saveInROMFolder == 0)
|
||||||
|
{
|
||||||
|
folderURL = FindSNESFolder(folderName);
|
||||||
|
if (folderURL == nil)
|
||||||
|
saveInROMFolder = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveInROMFolder == 4)
|
||||||
|
{
|
||||||
|
folderURL = FindCustomFolder(folderName);
|
||||||
|
if (folderURL == nil)
|
||||||
|
saveInROMFolder = 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveInROMFolder == 2)
|
||||||
|
folderURL = FindApplicationSupportFolder(folderName);
|
||||||
|
|
||||||
|
if (folderURL != nil)
|
||||||
|
{
|
||||||
|
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
||||||
|
snprintf(filePath[index], PATH_MAX + 1, "%s%s%s%s", folderURL.path.UTF8String, MAC_PATH_SEPARATOR, fname, inExt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
||||||
|
_makepath(filePath[index], drive, dir, fname, inExt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
|
||||||
|
_makepath(filePath[index], drive, dir, fname, inExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (filePath[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetSPCFilename (void)
|
||||||
|
{
|
||||||
|
char spcExt[16];
|
||||||
|
|
||||||
|
sprintf(spcExt, ".%03d.spc", (int) spcFileCount);
|
||||||
|
|
||||||
|
spcFileCount++;
|
||||||
|
if (spcFileCount == 1000)
|
||||||
|
spcFileCount = 0;
|
||||||
|
|
||||||
|
return (S9xGetFilename(spcExt, SPC_DIR));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetPNGFilename (void)
|
||||||
|
{
|
||||||
|
char pngExt[16];
|
||||||
|
|
||||||
|
sprintf(pngExt, ".%03d.png", (int) pngFileCount);
|
||||||
|
|
||||||
|
pngFileCount++;
|
||||||
|
if (pngFileCount == 1000)
|
||||||
|
pngFileCount = 0;
|
||||||
|
|
||||||
|
return (S9xGetFilename(pngExt, SCREENSHOT_DIR));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetFreezeFilename (int which)
|
||||||
|
{
|
||||||
|
char frzExt[16];
|
||||||
|
|
||||||
|
sprintf(frzExt, ".%03d.frz", which);
|
||||||
|
|
||||||
|
return (S9xGetFilename(frzExt, SNAPSHOT_DIR));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetFilenameInc (const char *inExt, enum s9x_getdirtype dirtype)
|
||||||
|
{
|
||||||
|
uint32 type;
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
if (strlen(inExt) < 4)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
p = inExt + strlen(inExt) - 4;
|
||||||
|
type = ((uint32) p[0] << 24) + ((uint32) p[1] << 16) + ((uint32) p[2] << 8) + (uint32) p[3];
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case '.spc':
|
||||||
|
return (S9xGetSPCFilename());
|
||||||
|
|
||||||
|
case '.png':
|
||||||
|
return (S9xGetPNGFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xChooseFilename (bool8 read_only)
|
||||||
|
{
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xChooseMovieFilename (bool8 read_only)
|
||||||
|
{
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 S9xOpenSnapshotFile (const char *fname, bool8 read_only, STREAM *file)
|
||||||
|
{
|
||||||
|
if (read_only)
|
||||||
|
{
|
||||||
|
if (0 != (*file = OPEN_STREAM(fname, "rb")))
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 != (*file = OPEN_STREAM(fname, "wb")))
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void S9xCloseSnapshotFile (STREAM file)
|
||||||
|
{
|
||||||
|
CLOSE_STREAM(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xBasename (const char *in)
|
||||||
|
{
|
||||||
|
static char s[PATH_MAX + 1];
|
||||||
|
|
||||||
|
strncpy(s, in, PATH_MAX + 1);
|
||||||
|
s[PATH_MAX] = 0;
|
||||||
|
|
||||||
|
size_t l = strlen(s);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < l; i++)
|
||||||
|
{
|
||||||
|
if (s[i] < 32 || s[i] >= 127)
|
||||||
|
s[i] = '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (basename(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * S9xGetDirectory (enum s9x_getdirtype dirtype)
|
||||||
|
{
|
||||||
|
static int index = 0;
|
||||||
|
static char path[4][PATH_MAX + 1];
|
||||||
|
|
||||||
|
char inExt[16];
|
||||||
|
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (index > 3)
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
switch (dirtype)
|
||||||
|
{
|
||||||
|
case SNAPSHOT_DIR: strcpy(inExt, ".frz"); break;
|
||||||
|
case SRAM_DIR: strcpy(inExt, ".srm"); break;
|
||||||
|
case SCREENSHOT_DIR: strcpy(inExt, ".png"); break;
|
||||||
|
case SPC_DIR: strcpy(inExt, ".spc"); break;
|
||||||
|
case CHEAT_DIR: strcpy(inExt, ".cht"); break;
|
||||||
|
case BIOS_DIR: strcpy(inExt, ".bio"); break;
|
||||||
|
case LOG_DIR: strcpy(inExt, ".log"); break;
|
||||||
|
default: strcpy(inExt, ".xxx"); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_splitpath(S9xGetFilename(inExt, dirtype), drive, dir, fname, ext);
|
||||||
|
_makepath(path[index], drive, dir, "", "");
|
||||||
|
|
||||||
|
size_t l = strlen(path[index]);
|
||||||
|
if (l > 1)
|
||||||
|
path[index][l - 1] = 0;
|
||||||
|
|
||||||
|
return (path[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
|
||||||
|
{
|
||||||
|
drive[0] = 0;
|
||||||
|
fname[0] = 0;
|
||||||
|
ext[0] = 0;
|
||||||
|
dir[0] = 0;
|
||||||
|
|
||||||
|
size_t x;
|
||||||
|
|
||||||
|
x = strlen(path) - 1;
|
||||||
|
if (x < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (x && (path[x] != MAC_PATH_SEP_CHAR))
|
||||||
|
x--;
|
||||||
|
|
||||||
|
if (x)
|
||||||
|
{
|
||||||
|
strcpy(dir, path);
|
||||||
|
dir[x + 1] = 0;
|
||||||
|
|
||||||
|
strcpy(fname, path + x + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(fname, path);
|
||||||
|
|
||||||
|
x = strlen(fname);
|
||||||
|
while (x && (fname[x] != '.'))
|
||||||
|
x--;
|
||||||
|
|
||||||
|
if (x)
|
||||||
|
{
|
||||||
|
strcpy(ext, fname + x);
|
||||||
|
fname[x] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _makepath (char *path, const char *drive, const char *dir, const char *fname, const char *ext)
|
||||||
|
{
|
||||||
|
static const char emp[] = "", dot[] = ".";
|
||||||
|
|
||||||
|
const char *d, *f, *e, *p;
|
||||||
|
|
||||||
|
d = dir ? dir : emp;
|
||||||
|
f = fname ? fname : emp;
|
||||||
|
e = ext ? ext : emp;
|
||||||
|
p = (e[0] && e[0] != '.') ? dot : emp;
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX + 1, "%s%s%s%s", d, f, p, e);
|
||||||
|
}
|
|
@ -57,12 +57,7 @@ void DrawSubCGImage (CGContextRef ctx, CGImageRef image, CGRect src, CGRect dst)
|
||||||
|
|
||||||
static void SetIconImage (CGImageRef image, CGRect rct, int n)
|
static void SetIconImage (CGImageRef image, CGRect rct, int n)
|
||||||
{
|
{
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
macIconImage[n] = CGImageCreateWithImageInRect(image, rct);
|
macIconImage[n] = CGImageCreateWithImageInRect(image, rct);
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
macIconRef[n] = CreateIconRefFromImage(image, rct);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateIconImages (void)
|
void CreateIconImages (void)
|
||||||
|
@ -159,20 +154,10 @@ void CreateIconImages (void)
|
||||||
void ReleaseIconImages (void)
|
void ReleaseIconImages (void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 118; i++)
|
for (int i = 0; i < 118; i++)
|
||||||
{
|
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
{
|
{
|
||||||
if (macIconImage[i])
|
if (macIconImage[i])
|
||||||
CGImageRelease(macIconImage[i]);
|
CGImageRelease(macIconImage[i]);
|
||||||
}
|
}
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (macIconRef[i])
|
|
||||||
ReleaseIconRef(macIconRef[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
#ifdef MAC_PANTHER_SUPPORT
|
||||||
if (systemVersion < 0x1040)
|
if (systemVersion < 0x1040)
|
File diff suppressed because it is too large
Load Diff
|
@ -158,7 +158,7 @@ enum
|
||||||
|
|
||||||
void SetUpHID (void);
|
void SetUpHID (void);
|
||||||
void ReleaseHID (void);
|
void ReleaseHID (void);
|
||||||
void ConfigureHID (void);
|
//void ConfigureHID (void);
|
||||||
void ClearPadSetting (void);
|
void ClearPadSetting (void);
|
||||||
void SaveControllerSettings (void);
|
void SaveControllerSettings (void);
|
||||||
void LoadControllerSettings (void);
|
void LoadControllerSettings (void);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -308,101 +308,101 @@ static OSStatus KeyLayoutEventHandler (EventHandlerCallRef, EventRef, void *);
|
||||||
|
|
||||||
void ConfigureKeyboard (void)
|
void ConfigureKeyboard (void)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
// OSStatus err;
|
||||||
IBNibRef nibRef;
|
// IBNibRef nibRef;
|
||||||
|
//
|
||||||
err = CreateNibReference(kMacS9XCFString, &nibRef);
|
// err = CreateNibReference(kMacS9XCFString, &nibRef);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
WindowRef tWindowRef;
|
// WindowRef tWindowRef;
|
||||||
|
//
|
||||||
err = CreateWindowFromNib(nibRef, CFSTR("Keyboard"), &tWindowRef);
|
// err = CreateWindowFromNib(nibRef, CFSTR("Keyboard"), &tWindowRef);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
EventHandlerRef wref, iref1, iref2;
|
// EventHandlerRef wref, iref1, iref2;
|
||||||
EventHandlerUPP wUPP, iUPP;
|
// EventHandlerUPP wUPP, iUPP;
|
||||||
EventTypeSpec wEvents[] = { { kEventClassWindow, kEventWindowClose },
|
// EventTypeSpec wEvents[] = { { kEventClassWindow, kEventWindowClose },
|
||||||
{ kEventClassCommand, kEventCommandProcess },
|
// { kEventClassCommand, kEventCommandProcess },
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } },
|
// { kEventClassCommand, kEventCommandUpdateStatus } },
|
||||||
cEvents[] = { { kEventClassHIObject, kEventHIObjectConstruct },
|
// cEvents[] = { { kEventClassHIObject, kEventHIObjectConstruct },
|
||||||
{ kEventClassHIObject, kEventHIObjectDestruct },
|
// { kEventClassHIObject, kEventHIObjectDestruct },
|
||||||
{ kEventClassHIObject, kEventHIObjectInitialize },
|
// { kEventClassHIObject, kEventHIObjectInitialize },
|
||||||
{ kEventClassControl, kEventControlDraw },
|
// { kEventClassControl, kEventControlDraw },
|
||||||
{ kEventClassControl, kEventControlHitTest },
|
// { kEventClassControl, kEventControlHitTest },
|
||||||
{ kEventClassControl, kEventControlTrack } },
|
// { kEventClassControl, kEventControlTrack } },
|
||||||
iEvents[] = { { kEventClassControl, kEventControlDraw } };
|
// iEvents[] = { { kEventClassControl, kEventControlDraw } };
|
||||||
HIObjectRef hiObject;
|
// HIObjectRef hiObject;
|
||||||
HIViewRef contentView, image1, image2;
|
// HIViewRef contentView, image1, image2;
|
||||||
HIViewID cid;
|
// HIViewID cid;
|
||||||
HIRect frame;
|
// HIRect frame;
|
||||||
Rect winBounds;
|
// Rect winBounds;
|
||||||
|
//
|
||||||
UpdateIconPlaceImage();
|
// UpdateIconPlaceImage();
|
||||||
|
//
|
||||||
keyInDrag = false;
|
// keyInDrag = false;
|
||||||
dragKey = -1;
|
// dragKey = -1;
|
||||||
dragKeyOfs = CGPointMake(0.0f, 0.0f);
|
// dragKeyOfs = CGPointMake(0.0f, 0.0f);
|
||||||
dragKeyRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
|
// dragKeyRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
mousePos = CGPointMake(0.0f, 0.0f);
|
// mousePos = CGPointMake(0.0f, 0.0f);
|
||||||
|
//
|
||||||
err = noErr;
|
// err = noErr;
|
||||||
if (theClass == NULL)
|
// if (theClass == NULL)
|
||||||
err = HIObjectRegisterSubclass(kCustomLayoutViewClassID, kHIViewClassID, 0, KeyLayoutEventHandler, GetEventTypeCount(cEvents), cEvents, NULL, &theClass);
|
// err = HIObjectRegisterSubclass(kCustomLayoutViewClassID, kHIViewClassID, 0, KeyLayoutEventHandler, GetEventTypeCount(cEvents), cEvents, NULL, &theClass);
|
||||||
|
//
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
err = HIObjectCreate(kCustomLayoutViewClassID, NULL, &hiObject);
|
// err = HIObjectCreate(kCustomLayoutViewClassID, NULL, &hiObject);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
GetWindowBounds(tWindowRef, kWindowContentRgn, &winBounds);
|
// GetWindowBounds(tWindowRef, kWindowContentRgn, &winBounds);
|
||||||
|
//
|
||||||
frame.origin.x = 2.0f;
|
// frame.origin.x = 2.0f;
|
||||||
frame.origin.y = 2.0f;
|
// frame.origin.y = 2.0f;
|
||||||
frame.size.width = (float) (winBounds.right - winBounds.left) - 4.0f;
|
// frame.size.width = (float) (winBounds.right - winBounds.left) - 4.0f;
|
||||||
frame.size.height = (float) kKeyLayoutHeight + 36.0f;
|
// frame.size.height = (float) kKeyLayoutHeight + 36.0f;
|
||||||
|
//
|
||||||
ofsx = (float) (((int) frame.size.width - kKeyLayoutWidth ) >> 1) + 1.0f;
|
// ofsx = (float) (((int) frame.size.width - kKeyLayoutWidth ) >> 1) + 1.0f;
|
||||||
ofsy = (float) (((int) frame.size.height - kKeyLayoutHeight) >> 1) + 1.0f;
|
// ofsy = (float) (((int) frame.size.height - kKeyLayoutHeight) >> 1) + 1.0f;
|
||||||
|
//
|
||||||
customView = (HIViewRef) hiObject;
|
// customView = (HIViewRef) hiObject;
|
||||||
|
//
|
||||||
HIViewFindByID(HIViewGetRoot(tWindowRef), kHIViewWindowContentID, &contentView);
|
// HIViewFindByID(HIViewGetRoot(tWindowRef), kHIViewWindowContentID, &contentView);
|
||||||
HIViewAddSubview(contentView, customView);
|
// HIViewAddSubview(contentView, customView);
|
||||||
HIViewSetFrame(customView, &frame);
|
// HIViewSetFrame(customView, &frame);
|
||||||
HIViewSetVisible(customView, true);
|
// HIViewSetVisible(customView, true);
|
||||||
|
//
|
||||||
cid.signature = 'Lgnd';
|
// cid.signature = 'Lgnd';
|
||||||
cid.id = 0;
|
// cid.id = 0;
|
||||||
HIViewFindByID(contentView, cid, &image1);
|
// HIViewFindByID(contentView, cid, &image1);
|
||||||
cid.id = 1;
|
// cid.id = 1;
|
||||||
HIViewFindByID(contentView, cid, &image2);
|
// HIViewFindByID(contentView, cid, &image2);
|
||||||
iUPP = NewEventHandlerUPP(KeyLegendEventHandler);
|
// iUPP = NewEventHandlerUPP(KeyLegendEventHandler);
|
||||||
err = InstallControlEventHandler(image1, iUPP, GetEventTypeCount(iEvents), iEvents, (void *) image1, &iref1);
|
// err = InstallControlEventHandler(image1, iUPP, GetEventTypeCount(iEvents), iEvents, (void *) image1, &iref1);
|
||||||
err = InstallControlEventHandler(image2, iUPP, GetEventTypeCount(iEvents), iEvents, (void *) image2, &iref2);
|
// err = InstallControlEventHandler(image2, iUPP, GetEventTypeCount(iEvents), iEvents, (void *) image2, &iref2);
|
||||||
|
//
|
||||||
wUPP = NewEventHandlerUPP(KeyWindowEventHandler);
|
// wUPP = NewEventHandlerUPP(KeyWindowEventHandler);
|
||||||
err = InstallWindowEventHandler(tWindowRef, wUPP, GetEventTypeCount(wEvents), wEvents, (void *) tWindowRef, &wref);
|
// err = InstallWindowEventHandler(tWindowRef, wUPP, GetEventTypeCount(wEvents), wEvents, (void *) tWindowRef, &wref);
|
||||||
|
//
|
||||||
MoveWindowPosition(tWindowRef, kWindowKeyConfig, false);
|
// MoveWindowPosition(tWindowRef, kWindowKeyConfig, false);
|
||||||
ShowWindow(tWindowRef);
|
// ShowWindow(tWindowRef);
|
||||||
err = RunAppModalLoopForWindow(tWindowRef);
|
// err = RunAppModalLoopForWindow(tWindowRef);
|
||||||
HideWindow(tWindowRef);
|
// HideWindow(tWindowRef);
|
||||||
SaveWindowPosition(tWindowRef, kWindowKeyConfig);
|
// SaveWindowPosition(tWindowRef, kWindowKeyConfig);
|
||||||
|
//
|
||||||
err = RemoveEventHandler(iref2);
|
// err = RemoveEventHandler(iref2);
|
||||||
err = RemoveEventHandler(iref1);
|
// err = RemoveEventHandler(iref1);
|
||||||
DisposeEventHandlerUPP(iUPP);
|
// DisposeEventHandlerUPP(iUPP);
|
||||||
|
//
|
||||||
err = RemoveEventHandler(wref);
|
// err = RemoveEventHandler(wref);
|
||||||
DisposeEventHandlerUPP(wUPP);
|
// DisposeEventHandlerUPP(wUPP);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
CFRelease(tWindowRef);
|
// CFRelease(tWindowRef);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
DisposeNibReference(nibRef);
|
// DisposeNibReference(nibRef);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateIconTableImage (void)
|
static void CreateIconTableImage (void)
|
||||||
|
@ -416,19 +416,19 @@ static void CreateIconTableImage (void)
|
||||||
|
|
||||||
iconTableCGWld = (Ptr) malloc(kIconSize * kKeys * (kIconSize + 1) * 4);
|
iconTableCGWld = (Ptr) malloc(kIconSize * kKeys * (kIconSize + 1) * 4);
|
||||||
if (!iconTableCGWld)
|
if (!iconTableCGWld)
|
||||||
QuitWithFatalError(0, "keyboard 08");
|
QuitWithFatalError(@"keyboard 08");
|
||||||
|
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
ctx = CGBitmapContextCreate(iconTableCGWld, kIconSize * kKeys, kIconSize, 8, kIconSize * kKeys * 4, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0));
|
ctx = CGBitmapContextCreate(iconTableCGWld, kIconSize * kKeys, kIconSize, 8, kIconSize * kKeys * 4, color, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrderDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
QuitWithFatalError(0, "keyboard 09");
|
QuitWithFatalError(@"keyboard 09");
|
||||||
|
|
||||||
CGContextTranslateCTM(ctx, 0.0f, (float) kIconSize);
|
CGContextTranslateCTM(ctx, 0.0f, (float) kIconSize);
|
||||||
CGContextScaleCTM(ctx, 1.0f, -1.0f);
|
CGContextScaleCTM(ctx, 1.0f, -1.0f);
|
||||||
|
@ -436,24 +436,13 @@ static void CreateIconTableImage (void)
|
||||||
// SNES pads
|
// SNES pads
|
||||||
for (int i = macPadIconIndex; i < macPadIconIndex + 12 * 2; i++)
|
for (int i = macPadIconIndex; i < macPadIconIndex + 12 * 2; i++)
|
||||||
{
|
{
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
CGContextDrawImage(ctx, rct, macIconImage[i]);
|
CGContextDrawImage(ctx, rct, macIconImage[i]);
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
PlotIconRefInContext(ctx, &rct, kAlignNone, kTransformNone, NULL, kPlotIconRefNormalFlags, macIconRef[i]);
|
|
||||||
#endif
|
|
||||||
rct = CGRectOffset(rct, kIconSize, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function buttons
|
// Function buttons
|
||||||
for (int i = macFunctionIconIndex; i < macFunctionIconIndex + 17; i++)
|
for (int i = macFunctionIconIndex; i < macFunctionIconIndex + 17; i++)
|
||||||
{
|
{
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
CGContextDrawImage(ctx, rct, macIconImage[i]);
|
CGContextDrawImage(ctx, rct, macIconImage[i]);
|
||||||
#ifdef MAC_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
PlotIconRefInContext(ctx, &rct, kAlignNone, kTransformNone, NULL, kPlotIconRefNormalFlags, macIconRef[i]);
|
|
||||||
#endif
|
|
||||||
rct = CGRectOffset(rct, kIconSize, 0);
|
rct = CGRectOffset(rct, kIconSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +456,7 @@ static void CreateIconTableImage (void)
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
iconTableImage = CGImageCreate(kIconSize * kKeys, kIconSize, 8, 32, kIconSize * kKeys * 4, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0), prov, NULL, 0, kCGRenderingIntentDefault);
|
iconTableImage = CGImageCreate(kIconSize * kKeys, kIconSize, 8, 32, kIconSize * kKeys * 4, color, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrderDefault, prov, NULL, 0, kCGRenderingIntentDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +464,7 @@ static void CreateIconTableImage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iconTableImage)
|
if (!iconTableImage)
|
||||||
QuitWithFatalError(0, "keyboard 10");
|
QuitWithFatalError(@"keyboard 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseIconTableImage (void)
|
static void ReleaseIconTableImage (void)
|
||||||
|
@ -499,19 +488,19 @@ static void CreateKeyLayoutImage (void)
|
||||||
|
|
||||||
keyLayoutWorld = (Ptr) malloc(kKeyLayoutWidth * (kKeyLayoutHeight + 1) * 4);
|
keyLayoutWorld = (Ptr) malloc(kKeyLayoutWidth * (kKeyLayoutHeight + 1) * 4);
|
||||||
if (!keyLayoutWorld)
|
if (!keyLayoutWorld)
|
||||||
QuitWithFatalError(0, "keyboard 02");
|
QuitWithFatalError(@"keyboard 02");
|
||||||
|
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
ctx = CGBitmapContextCreate(keyLayoutWorld, kKeyLayoutWidth, kKeyLayoutHeight, 8, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0));
|
ctx = CGBitmapContextCreate(keyLayoutWorld, kKeyLayoutWidth, kKeyLayoutHeight, 8, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
QuitWithFatalError(0, "keyboard 04");
|
QuitWithFatalError(@"keyboard 04");
|
||||||
|
|
||||||
CGContextSetLineJoin(ctx, kCGLineJoinMiter);
|
CGContextSetLineJoin(ctx, kCGLineJoinMiter);
|
||||||
|
|
||||||
|
@ -587,7 +576,7 @@ static void CreateKeyLayoutImage (void)
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
keyLayoutImage = CGImageCreate(kKeyLayoutWidth, kKeyLayoutHeight, 8, 32, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0), prov, NULL, 0, kCGRenderingIntentDefault);
|
keyLayoutImage = CGImageCreate(kKeyLayoutWidth, kKeyLayoutHeight, 8, 32, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault, prov, NULL, 0, kCGRenderingIntentDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +584,7 @@ static void CreateKeyLayoutImage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!keyLayoutImage)
|
if (!keyLayoutImage)
|
||||||
QuitWithFatalError(0, "keyboard 05");
|
QuitWithFatalError(@"keyboard 05");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseKeyLayoutImage (void)
|
static void ReleaseKeyLayoutImage (void)
|
||||||
|
@ -608,7 +597,7 @@ static void CreateIconPlaceImage (void)
|
||||||
{
|
{
|
||||||
iconPlaceWorld = (Ptr) malloc(kKeyLayoutWidth * (kKeyLayoutHeight + 1) * 4);
|
iconPlaceWorld = (Ptr) malloc(kKeyLayoutWidth * (kKeyLayoutHeight + 1) * 4);
|
||||||
if (!iconPlaceWorld)
|
if (!iconPlaceWorld)
|
||||||
QuitWithFatalError(0, "keyboard 06");
|
QuitWithFatalError(@"keyboard 06");
|
||||||
|
|
||||||
iconPlaceImage = NULL;
|
iconPlaceImage = NULL;
|
||||||
|
|
||||||
|
@ -630,7 +619,7 @@ static void UpdateIconPlaceImage (void)
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
ctx = CGBitmapContextCreate(iconPlaceWorld, kKeyLayoutWidth, kKeyLayoutHeight, 8, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0));
|
ctx = CGBitmapContextCreate(iconPlaceWorld, kKeyLayoutWidth, kKeyLayoutHeight, 8, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault);
|
||||||
if (ctx)
|
if (ctx)
|
||||||
{
|
{
|
||||||
rct = CGRectMake(0.0f, 0.0f, (float) kKeyLayoutWidth, (float) kKeyLayoutHeight);
|
rct = CGRectMake(0.0f, 0.0f, (float) kKeyLayoutWidth, (float) kKeyLayoutHeight);
|
||||||
|
@ -645,7 +634,7 @@ static void UpdateIconPlaceImage (void)
|
||||||
prov = CGDataProviderCreateWithData(NULL, iconPlaceWorld, kKeyLayoutWidth * kKeyLayoutHeight * 4, NULL);
|
prov = CGDataProviderCreateWithData(NULL, iconPlaceWorld, kKeyLayoutWidth * kKeyLayoutHeight * 4, NULL);
|
||||||
if (prov)
|
if (prov)
|
||||||
{
|
{
|
||||||
iconPlaceImage = CGImageCreate(kKeyLayoutWidth, kKeyLayoutHeight, 8, 32, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrderDefault : 0), prov, NULL, 0, kCGRenderingIntentDefault);
|
iconPlaceImage = CGImageCreate(kKeyLayoutWidth, kKeyLayoutHeight, 8, 32, kKeyLayoutWidth * 4, color, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault, prov, NULL, 0, kCGRenderingIntentDefault);
|
||||||
CGDataProviderRelease(prov);
|
CGDataProviderRelease(prov);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +642,7 @@ static void UpdateIconPlaceImage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iconPlaceImage)
|
if (!iconPlaceImage)
|
||||||
QuitWithFatalError(0, "keyboard 07");
|
QuitWithFatalError(@"keyboard 07");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseIconPlaceImage (void)
|
static void ReleaseIconPlaceImage (void)
|
||||||
|
@ -782,253 +771,257 @@ static int FindHitKey (HIPoint where, CGRect *keybounds, CGPoint *offset)
|
||||||
|
|
||||||
static OSStatus KeyWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
static OSStatus KeyWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
{
|
{
|
||||||
OSStatus err, result = eventNotHandledErr;
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
WindowRef tWindowRef = (WindowRef) inUserData;
|
// WindowRef tWindowRef = (WindowRef) inUserData;
|
||||||
|
//
|
||||||
switch (GetEventClass(inEvent))
|
// switch (GetEventClass(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventClassWindow:
|
// case kEventClassWindow:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventWindowClose:
|
// case kEventWindowClose:
|
||||||
QuitAppModalLoopForWindow(tWindowRef);
|
// QuitAppModalLoopForWindow(tWindowRef);
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventClassCommand:
|
// case kEventClassCommand:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
HICommand tHICommand;
|
// HICommand tHICommand;
|
||||||
|
//
|
||||||
case kEventCommandUpdateStatus:
|
// case kEventCommandUpdateStatus:
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
if (err == noErr && tHICommand.commandID == 'clos')
|
// if (err == noErr && tHICommand.commandID == 'clos')
|
||||||
{
|
// {
|
||||||
UpdateMenuCommandStatus(true);
|
// UpdateMenuCommandStatus(true);
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventCommandProcess:
|
// case kEventCommandProcess:
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
if (tHICommand.commandID == 'DFLT')
|
// if (tHICommand.commandID == 'DFLT')
|
||||||
{
|
// {
|
||||||
memcpy(keyCode, defaultKeys, sizeof(keyCode));
|
// memcpy(keyCode, defaultKeys, sizeof(keyCode));
|
||||||
UpdateIconPlaceImage();
|
// UpdateIconPlaceImage();
|
||||||
HIViewSetNeedsDisplay(customView, true);
|
// HIViewSetNeedsDisplay(customView, true);
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return (result);
|
// return (result);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus KeyLegendEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
static OSStatus KeyLegendEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
{
|
{
|
||||||
OSStatus err, result = eventNotHandledErr;
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
HIViewRef view = (HIViewRef) inUserData;
|
// HIViewRef view = (HIViewRef) inUserData;
|
||||||
|
//
|
||||||
|
// switch (GetEventClass(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventClassControl:
|
||||||
|
// switch (GetEventKind(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventControlDraw:
|
||||||
|
// CGContextRef ctx;
|
||||||
|
//
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &ctx);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// HIViewID cid;
|
||||||
|
// HIRect bounds;
|
||||||
|
//
|
||||||
|
// GetControlID(view, &cid);
|
||||||
|
// HIViewGetBounds(view, &bounds);
|
||||||
|
// CGContextTranslateCTM(ctx, 0, bounds.size.height);
|
||||||
|
// CGContextScaleCTM(ctx, 1.0f, -1.0f);
|
||||||
|
// CGContextDrawImage(ctx, CGRectMake(0, 0, kIconSize, kIconSize), macIconImage[macLegendIconIndex + cid.id]);
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (result);
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
return 0;
|
||||||
{
|
|
||||||
case kEventClassControl:
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
case kEventControlDraw:
|
|
||||||
CGContextRef ctx;
|
|
||||||
|
|
||||||
err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &ctx);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
HIViewID cid;
|
|
||||||
HIRect bounds;
|
|
||||||
|
|
||||||
GetControlID(view, &cid);
|
|
||||||
HIViewGetBounds(view, &bounds);
|
|
||||||
CGContextTranslateCTM(ctx, 0, bounds.size.height);
|
|
||||||
CGContextScaleCTM(ctx, 1.0f, -1.0f);
|
|
||||||
CGContextDrawImage(ctx, CGRectMake(0, 0, kIconSize, kIconSize), macIconImage[macLegendIconIndex + cid.id]);
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus KeyLayoutEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
static OSStatus KeyLayoutEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
{
|
{
|
||||||
OSStatus err, result = eventNotHandledErr;
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
CustomViewData *data = (CustomViewData *) inUserData;
|
// CustomViewData *data = (CustomViewData *) inUserData;
|
||||||
|
//
|
||||||
switch (GetEventClass(inEvent))
|
// switch (GetEventClass(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventClassHIObject:
|
// case kEventClassHIObject:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventHIObjectConstruct:
|
// case kEventHIObjectConstruct:
|
||||||
data = (CustomViewData *) calloc(1, sizeof(CustomViewData));
|
// data = (CustomViewData *) calloc(1, sizeof(CustomViewData));
|
||||||
if (data)
|
// if (data)
|
||||||
{
|
// {
|
||||||
HIViewRef epView;
|
// HIViewRef epView;
|
||||||
|
//
|
||||||
err = GetEventParameter(inEvent, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(epView), NULL, &epView);
|
// err = GetEventParameter(inEvent, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(epView), NULL, &epView);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
data->view = epView;
|
// data->view = epView;
|
||||||
result = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(data), &data);
|
// result = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(data), &data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventHIObjectDestruct:
|
// case kEventHIObjectDestruct:
|
||||||
if (data)
|
// if (data)
|
||||||
free(data);
|
// free(data);
|
||||||
|
//
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventHIObjectInitialize:
|
// case kEventHIObjectInitialize:
|
||||||
result = CallNextEventHandler(inHandlerRef, inEvent);
|
// result = CallNextEventHandler(inHandlerRef, inEvent);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventClassControl:
|
// case kEventClassControl:
|
||||||
switch (GetEventKind(inEvent))
|
// switch (GetEventKind(inEvent))
|
||||||
{
|
// {
|
||||||
case kEventControlDraw:
|
// case kEventControlDraw:
|
||||||
CGContextRef ctx;
|
// CGContextRef ctx;
|
||||||
|
//
|
||||||
err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(ctx), NULL, &ctx);
|
// err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(ctx), NULL, &ctx);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
HIRect bounds, srcRect, dstRect;
|
// HIRect bounds, srcRect, dstRect;
|
||||||
|
//
|
||||||
HIViewGetBounds(customView, &bounds);
|
// HIViewGetBounds(customView, &bounds);
|
||||||
srcRect = CGRectMake(0, 0, kKeyLayoutWidth, kKeyLayoutHeight);
|
// srcRect = CGRectMake(0, 0, kKeyLayoutWidth, kKeyLayoutHeight);
|
||||||
|
//
|
||||||
dstRect.origin.x = (float) (((int) bounds.size.width - kKeyLayoutWidth ) >> 1);
|
// dstRect.origin.x = (float) (((int) bounds.size.width - kKeyLayoutWidth ) >> 1);
|
||||||
dstRect.origin.y = (float) (((int) bounds.size.height - kKeyLayoutHeight) >> 1);
|
// dstRect.origin.y = (float) (((int) bounds.size.height - kKeyLayoutHeight) >> 1);
|
||||||
dstRect.size.width = (float) kKeyLayoutWidth;
|
// dstRect.size.width = (float) kKeyLayoutWidth;
|
||||||
dstRect.size.height = (float) kKeyLayoutHeight;
|
// dstRect.size.height = (float) kKeyLayoutHeight;
|
||||||
|
//
|
||||||
DrawSubCGImage(ctx, iconPlaceImage, srcRect, dstRect);
|
// DrawSubCGImage(ctx, iconPlaceImage, srcRect, dstRect);
|
||||||
if (keyInDrag && (dragKey != -1))
|
// if (keyInDrag && (dragKey != -1))
|
||||||
DrawDraggedIcon(ctx, dragKey, &dragKeyOfs);
|
// DrawDraggedIcon(ctx, dragKey, &dragKeyOfs);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventControlHitTest:
|
// case kEventControlHitTest:
|
||||||
ControlPartCode part;
|
// ControlPartCode part;
|
||||||
|
//
|
||||||
part = kControlButtonPart;
|
// part = kControlButtonPart;
|
||||||
result = SetEventParameter(inEvent, kEventParamControlPart, typeControlPartCode, sizeof(part), &part);
|
// result = SetEventParameter(inEvent, kEventParamControlPart, typeControlPartCode, sizeof(part), &part);
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case kEventControlTrack:
|
// case kEventControlTrack:
|
||||||
MouseTrackingResult trackResult;
|
// MouseTrackingResult trackResult;
|
||||||
WindowRef window;
|
// WindowRef window;
|
||||||
HIViewRef contentView;
|
// HIViewRef contentView;
|
||||||
HIPoint hipt;
|
// HIPoint hipt;
|
||||||
|
//
|
||||||
dragKey = -1;
|
// dragKey = -1;
|
||||||
dragKeyOfs = CGPointMake(0.0f, 0.0f);
|
// dragKeyOfs = CGPointMake(0.0f, 0.0f);
|
||||||
dragKeyRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
|
// dragKeyRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
mousePos = CGPointMake(0.0f, 0.0f);
|
// mousePos = CGPointMake(0.0f, 0.0f);
|
||||||
trackResult = kMouseTrackingMouseDown;
|
// trackResult = kMouseTrackingMouseDown;
|
||||||
|
//
|
||||||
window = GetControlOwner(customView);
|
// window = GetControlOwner(customView);
|
||||||
HIViewFindByID(HIViewGetRoot(window), kHIViewWindowContentID, &contentView);
|
// HIViewFindByID(HIViewGetRoot(window), kHIViewWindowContentID, &contentView);
|
||||||
|
//
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
// #ifdef MAC_TIGER_PANTHER_SUPPORT
|
||||||
CGrafPtr oldPort;
|
// CGrafPtr oldPort;
|
||||||
Point qdpt;
|
// Point qdpt;
|
||||||
Boolean portChanged = false;
|
// Boolean portChanged = false;
|
||||||
|
//
|
||||||
if (systemVersion < 0x1050)
|
// if (systemVersion < 0x1050)
|
||||||
portChanged = QDSwapPort(GetWindowPort(window), &oldPort);
|
// portChanged = QDSwapPort(GetWindowPort(window), &oldPort);
|
||||||
#endif
|
// #endif
|
||||||
|
//
|
||||||
err = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(hipt), NULL, &hipt);
|
// err = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(hipt), NULL, &hipt);
|
||||||
if (err == noErr)
|
// if (err == noErr)
|
||||||
{
|
// {
|
||||||
hipt.x -= ofsx;
|
// hipt.x -= ofsx;
|
||||||
hipt.y -= ofsy;
|
// hipt.y -= ofsy;
|
||||||
|
//
|
||||||
dragKey = FindHitKey(hipt, &dragKeyRect, &dragKeyOfs);
|
// dragKey = FindHitKey(hipt, &dragKeyRect, &dragKeyOfs);
|
||||||
if (dragKey != -1)
|
// if (dragKey != -1)
|
||||||
{
|
// {
|
||||||
keyInDrag = true;
|
// keyInDrag = true;
|
||||||
|
//
|
||||||
while (trackResult != kMouseTrackingMouseUp)
|
// while (trackResult != kMouseTrackingMouseUp)
|
||||||
{
|
// {
|
||||||
if (CGPointEqualToPoint(mousePos, hipt) == 0)
|
// if (CGPointEqualToPoint(mousePos, hipt) == 0)
|
||||||
{
|
// {
|
||||||
mousePos = hipt;
|
// mousePos = hipt;
|
||||||
HIViewSetNeedsDisplay(customView, true);
|
// HIViewSetNeedsDisplay(customView, true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (systemVersion >= 0x1050)
|
// if (systemVersion >= 0x1050)
|
||||||
{
|
// {
|
||||||
err = HIViewTrackMouseLocation(customView, 0, kEventDurationForever, 0, NULL, &hipt, NULL, NULL, &trackResult);
|
// err = HIViewTrackMouseLocation(customView, 0, kEventDurationForever, 0, NULL, &hipt, NULL, NULL, &trackResult);
|
||||||
hipt.x -= ofsx;
|
// hipt.x -= ofsx;
|
||||||
hipt.y -= ofsy;
|
// hipt.y -= ofsy;
|
||||||
}
|
// }
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
// #ifdef MAC_TIGER_PANTHER_SUPPORT
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
TrackMouseLocation(NULL, &qdpt, &trackResult);
|
// TrackMouseLocation(NULL, &qdpt, &trackResult);
|
||||||
hipt.x = qdpt.h - ofsx;
|
// hipt.x = qdpt.h - ofsx;
|
||||||
hipt.y = qdpt.v - ofsy;
|
// hipt.y = qdpt.v - ofsy;
|
||||||
HIViewConvertPoint(&hipt, contentView, customView);
|
// HIViewConvertPoint(&hipt, contentView, customView);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
keyInDrag = false;
|
// keyInDrag = false;
|
||||||
|
//
|
||||||
for (int code = 0; code < 0x80; code++)
|
// for (int code = 0; code < 0x80; code++)
|
||||||
{
|
// {
|
||||||
for (int each = 0; each <= 1; each++)
|
// for (int each = 0; each <= 1; each++)
|
||||||
{
|
// {
|
||||||
if (CGRectContainsPoint(keyRect[code][each], mousePos))
|
// if (CGRectContainsPoint(keyRect[code][each], mousePos))
|
||||||
{
|
// {
|
||||||
if (!KeyCodeInUse(code))
|
// if (!KeyCodeInUse(code))
|
||||||
{
|
// {
|
||||||
keyCode[dragKey] = code;
|
// keyCode[dragKey] = code;
|
||||||
UpdateIconPlaceImage();
|
// UpdateIconPlaceImage();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
HIViewSetNeedsDisplay(customView, true);
|
// HIViewSetNeedsDisplay(customView, true);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
// #ifdef MAC_TIGER_PANTHER_SUPPORT
|
||||||
if (systemVersion < 0x1050)
|
// if (systemVersion < 0x1050)
|
||||||
{
|
// {
|
||||||
if (portChanged)
|
// if (portChanged)
|
||||||
QDSwapPort(oldPort, NULL);
|
// QDSwapPort(oldPort, NULL);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
//
|
||||||
result = noErr;
|
// result = noErr;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return (result);
|
// return (result);
|
||||||
|
return 0;
|
||||||
}
|
}
|
|
@ -1,534 +0,0 @@
|
||||||
/*****************************************************************************\
|
|
||||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
||||||
This file is licensed under the Snes9x License.
|
|
||||||
For further information, consult the LICENSE file in the root directory.
|
|
||||||
\*****************************************************************************/
|
|
||||||
|
|
||||||
/***********************************************************************************
|
|
||||||
SNES9X for Mac OS (c) Copyright John Stiles
|
|
||||||
|
|
||||||
Snes9x for Mac OS X
|
|
||||||
|
|
||||||
(c) Copyright 2001 - 2011 zones
|
|
||||||
(c) Copyright 2002 - 2005 107
|
|
||||||
(c) Copyright 2002 PB1400c
|
|
||||||
(c) Copyright 2004 Alexander and Sander
|
|
||||||
(c) Copyright 2004 - 2005 Steven Seeger
|
|
||||||
(c) Copyright 2005 Ryan Vogt
|
|
||||||
***********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "port.h"
|
|
||||||
|
|
||||||
#include "mac-prefix.h"
|
|
||||||
#include "mac-cart.h"
|
|
||||||
#include "mac-dialog.h"
|
|
||||||
#include "mac-os.h"
|
|
||||||
#include "mac-multicart.h"
|
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
|
||||||
#define truncEnd 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static OSStatus MultiCartEventHandler (EventHandlerCallRef, EventRef, void *);
|
|
||||||
static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef, EventRef, void *);
|
|
||||||
|
|
||||||
static int multiCartDragHilite;
|
|
||||||
static Boolean multiCartDialogResult;
|
|
||||||
|
|
||||||
void InitMultiCart (void)
|
|
||||||
{
|
|
||||||
CFStringRef keyRef, pathRef;
|
|
||||||
char key[32];
|
|
||||||
|
|
||||||
multiCartPath[0] = multiCartPath[1] = NULL;
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
sprintf(key, "MultiCartPath_%02d", i);
|
|
||||||
keyRef = CFStringCreateWithCString(kCFAllocatorDefault, key, CFStringGetSystemEncoding());
|
|
||||||
if (keyRef)
|
|
||||||
{
|
|
||||||
pathRef = (CFStringRef) CFPreferencesCopyAppValue(keyRef, kCFPreferencesCurrentApplication);
|
|
||||||
if (pathRef)
|
|
||||||
multiCartPath[i] = pathRef;
|
|
||||||
|
|
||||||
CFRelease(keyRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeinitMultiCart (void)
|
|
||||||
{
|
|
||||||
CFStringRef keyRef;
|
|
||||||
char key[32];
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
sprintf(key, "MultiCartPath_%02d", i);
|
|
||||||
keyRef = CFStringCreateWithCString(kCFAllocatorDefault, key, CFStringGetSystemEncoding());
|
|
||||||
if (keyRef)
|
|
||||||
{
|
|
||||||
if (multiCartPath[i])
|
|
||||||
{
|
|
||||||
CFPreferencesSetAppValue(keyRef, multiCartPath[i], kCFPreferencesCurrentApplication);
|
|
||||||
CFRelease(multiCartPath[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
CFPreferencesSetAppValue(keyRef, NULL, kCFPreferencesCurrentApplication);
|
|
||||||
|
|
||||||
CFRelease(keyRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean MultiCartDialog (void)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
IBNibRef nibRef;
|
|
||||||
|
|
||||||
multiCartDragHilite = -1;
|
|
||||||
multiCartDialogResult = false;
|
|
||||||
|
|
||||||
err = CreateNibReference(kMacS9XCFString, &nibRef);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
WindowRef window;
|
|
||||||
|
|
||||||
err = CreateWindowFromNib(nibRef, CFSTR("MultiCart"), &window);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
static int index[2] = { 0, 1 };
|
|
||||||
|
|
||||||
EventHandlerRef wRef, cRef[2];
|
|
||||||
EventHandlerUPP wUPP, cUPP[2];
|
|
||||||
EventTypeSpec wEvent[] = { { kEventClassCommand, kEventCommandProcess },
|
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } },
|
|
||||||
cEvent[] = { { kEventClassControl, kEventControlDraw },
|
|
||||||
{ kEventClassControl, kEventControlDragEnter },
|
|
||||||
{ kEventClassControl, kEventControlDragWithin },
|
|
||||||
{ kEventClassControl, kEventControlDragLeave },
|
|
||||||
{ kEventClassControl, kEventControlDragReceive } };
|
|
||||||
HIViewRef ctl, root, pane[2];
|
|
||||||
HIViewID cid;
|
|
||||||
|
|
||||||
root = HIViewGetRoot(window);
|
|
||||||
|
|
||||||
wUPP = NewEventHandlerUPP(MultiCartEventHandler);
|
|
||||||
err = InstallWindowEventHandler(window, wUPP, GetEventTypeCount(wEvent), wEvent, (void *) window, &wRef);
|
|
||||||
err = SetAutomaticControlDragTrackingEnabledForWindow(window, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
cid.id = i;
|
|
||||||
|
|
||||||
cid.signature = 'MPan';
|
|
||||||
HIViewFindByID(root, cid, &pane[i]);
|
|
||||||
cUPP[i] = NewEventHandlerUPP(MultiCartPaneEventHandler);
|
|
||||||
err = InstallControlEventHandler(pane[i], cUPP[i], GetEventTypeCount(cEvent), cEvent, (void *) &index[i], &cRef[i]);
|
|
||||||
err = SetControlDragTrackingEnabled(pane[i], true);
|
|
||||||
|
|
||||||
cid.signature = 'MNAM';
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
SetStaticTextTrunc(ctl, truncEnd, false);
|
|
||||||
if (multiCartPath[i])
|
|
||||||
{
|
|
||||||
CFStringRef str;
|
|
||||||
CFURLRef url;
|
|
||||||
|
|
||||||
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, multiCartPath[i], kCFURLPOSIXPathStyle, false);
|
|
||||||
str = CFURLCopyLastPathComponent(url);
|
|
||||||
SetStaticTextCFString(ctl, str, false);
|
|
||||||
CFRelease(str);
|
|
||||||
CFRelease(url);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetStaticTextCFString(ctl, CFSTR(""), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
MoveWindowPosition(window, kWindowMultiCart, false);
|
|
||||||
ShowWindow(window);
|
|
||||||
err = RunAppModalLoopForWindow(window);
|
|
||||||
HideWindow(window);
|
|
||||||
SaveWindowPosition(window, kWindowMultiCart);
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
err = RemoveEventHandler(cRef[i]);
|
|
||||||
DisposeEventHandlerUPP(cUPP[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
err = RemoveEventHandler(wRef);
|
|
||||||
DisposeEventHandlerUPP(wUPP);
|
|
||||||
|
|
||||||
CFRelease(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
DisposeNibReference(nibRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (multiCartDialogResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus MultiCartEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
|
||||||
{
|
|
||||||
OSStatus err, result = eventNotHandledErr;
|
|
||||||
WindowRef window = (WindowRef) inUserData;
|
|
||||||
static int index = -1;
|
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
|
||||||
{
|
|
||||||
case kEventClassCommand:
|
|
||||||
{
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
HICommand tHICommand;
|
|
||||||
|
|
||||||
case kEventCommandUpdateStatus:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr && tHICommand.commandID == 'clos')
|
|
||||||
{
|
|
||||||
UpdateMenuCommandStatus(false);
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEventCommandProcess:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
HIViewRef ctl, root;
|
|
||||||
HIViewID cid;
|
|
||||||
FSRef ref;
|
|
||||||
bool8 r;
|
|
||||||
|
|
||||||
root = HIViewGetRoot(window);
|
|
||||||
|
|
||||||
switch (tHICommand.commandID)
|
|
||||||
{
|
|
||||||
case 'Cho0':
|
|
||||||
case 'Cho1':
|
|
||||||
{
|
|
||||||
index = (tHICommand.commandID & 0xFF) - '0';
|
|
||||||
r = NavBeginOpenROMImageSheet(window, NULL);
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'NvDn':
|
|
||||||
{
|
|
||||||
r = NavEndOpenROMImageSheet(&ref);
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
CFStringRef str;
|
|
||||||
CFURLRef url;
|
|
||||||
|
|
||||||
url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref);
|
|
||||||
str = CFURLCopyLastPathComponent(url);
|
|
||||||
cid.signature = 'MNAM';
|
|
||||||
cid.id = index;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
SetStaticTextCFString(ctl, str, true);
|
|
||||||
CFRelease(str);
|
|
||||||
str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
|
||||||
if (multiCartPath[index])
|
|
||||||
CFRelease(multiCartPath[index]);
|
|
||||||
multiCartPath[index] = str;
|
|
||||||
CFRelease(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
index = -1;
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'Cle0':
|
|
||||||
case 'Cle1':
|
|
||||||
{
|
|
||||||
index = (tHICommand.commandID & 0xFF) - '0';
|
|
||||||
cid.signature = 'MNAM';
|
|
||||||
cid.id = index;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
SetStaticTextCFString(ctl, CFSTR(""), true);
|
|
||||||
if (multiCartPath[index])
|
|
||||||
{
|
|
||||||
CFRelease(multiCartPath[index]);
|
|
||||||
multiCartPath[index] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
index = -1;
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'SWAP':
|
|
||||||
{
|
|
||||||
CFStringRef str;
|
|
||||||
CFURLRef url;
|
|
||||||
|
|
||||||
str = multiCartPath[0];
|
|
||||||
multiCartPath[0] = multiCartPath[1];
|
|
||||||
multiCartPath[1] = str;
|
|
||||||
|
|
||||||
cid.signature = 'MNAM';
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
cid.id = i;
|
|
||||||
HIViewFindByID(root, cid, &ctl);
|
|
||||||
|
|
||||||
if (multiCartPath[i])
|
|
||||||
{
|
|
||||||
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, multiCartPath[i], kCFURLPOSIXPathStyle, false);
|
|
||||||
str = CFURLCopyLastPathComponent(url);
|
|
||||||
SetStaticTextCFString(ctl, str, true);
|
|
||||||
CFRelease(str);
|
|
||||||
CFRelease(url);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetStaticTextCFString(ctl, CFSTR(""), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'ok ':
|
|
||||||
{
|
|
||||||
QuitAppModalLoopForWindow(window);
|
|
||||||
multiCartDialogResult = true;
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'not!':
|
|
||||||
{
|
|
||||||
QuitAppModalLoopForWindow(window);
|
|
||||||
multiCartDialogResult = false;
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
|
||||||
{
|
|
||||||
OSStatus err, result = eventNotHandledErr;
|
|
||||||
HIViewRef view;
|
|
||||||
DragRef drag;
|
|
||||||
PasteboardRef pasteboard;
|
|
||||||
PasteboardItemID itemID;
|
|
||||||
CFArrayRef array;
|
|
||||||
CFStringRef flavorType;
|
|
||||||
CFIndex numFlavors;
|
|
||||||
ItemCount numItems;
|
|
||||||
int index = *((int *) inUserData);
|
|
||||||
|
|
||||||
switch (GetEventClass(inEvent))
|
|
||||||
{
|
|
||||||
case kEventClassControl:
|
|
||||||
{
|
|
||||||
switch (GetEventKind(inEvent))
|
|
||||||
{
|
|
||||||
case kEventControlDraw:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
CGContextRef ctx;
|
|
||||||
|
|
||||||
err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &ctx);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
HIThemeFrameDrawInfo info;
|
|
||||||
HIRect bounds, frame;
|
|
||||||
|
|
||||||
HIViewGetBounds(view, &bounds);
|
|
||||||
|
|
||||||
CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
CGContextFillRect(ctx, bounds);
|
|
||||||
|
|
||||||
info.version = 0;
|
|
||||||
info.kind = kHIThemeFrameTextFieldSquare;
|
|
||||||
info.state = kThemeStateInactive;
|
|
||||||
info.isFocused = false;
|
|
||||||
err = HIThemeDrawFrame(&bounds, &info, ctx, kHIThemeOrientationNormal);
|
|
||||||
|
|
||||||
if (multiCartDragHilite == index && systemVersion >= 0x1040)
|
|
||||||
{
|
|
||||||
err = HIThemeSetStroke(kThemeBrushDragHilite, NULL, ctx, kHIThemeOrientationNormal);
|
|
||||||
frame = CGRectInset(bounds, 1, 1);
|
|
||||||
CGContextBeginPath(ctx);
|
|
||||||
CGContextAddRect(ctx, frame);
|
|
||||||
CGContextStrokePath(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEventControlDragEnter:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDragRef, typeDragRef, NULL, sizeof(DragRef), NULL, &drag);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = GetDragPasteboard(drag, &pasteboard);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = PasteboardGetItemCount(pasteboard, &numItems);
|
|
||||||
if (err == noErr && numItems == 1)
|
|
||||||
{
|
|
||||||
err = PasteboardGetItemIdentifier(pasteboard, 1, &itemID);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = PasteboardCopyItemFlavors(pasteboard, itemID, &array);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
numFlavors = CFArrayGetCount(array);
|
|
||||||
for (CFIndex i = 0; i < numFlavors; i++)
|
|
||||||
{
|
|
||||||
flavorType = (CFStringRef) CFArrayGetValueAtIndex(array, i);
|
|
||||||
if (UTTypeConformsTo(flavorType, CFSTR("public.file-url")))
|
|
||||||
{
|
|
||||||
Boolean accept = true;
|
|
||||||
|
|
||||||
err = SetEventParameter(inEvent, kEventParamControlWouldAcceptDrop, typeBoolean, sizeof(Boolean), &accept);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
multiCartDragHilite = index;
|
|
||||||
HIViewSetNeedsDisplay(view, true);
|
|
||||||
result = noErr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEventControlDragWithin:
|
|
||||||
{
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEventControlDragLeave:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
multiCartDragHilite = -1;
|
|
||||||
HIViewSetNeedsDisplay(view, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEventControlDragReceive:
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = GetEventParameter(inEvent, kEventParamDragRef, typeDragRef, NULL, sizeof(DragRef), NULL, &drag);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
multiCartDragHilite = -1;
|
|
||||||
HIViewSetNeedsDisplay(view, true);
|
|
||||||
|
|
||||||
err = GetDragPasteboard(drag, &pasteboard);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = PasteboardGetItemIdentifier(pasteboard, 1, &itemID);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
err = PasteboardCopyItemFlavors(pasteboard, itemID, &array);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
numFlavors = CFArrayGetCount(array);
|
|
||||||
for (CFIndex i = 0; i < numFlavors; i++)
|
|
||||||
{
|
|
||||||
flavorType = (CFStringRef) CFArrayGetValueAtIndex(array, i);
|
|
||||||
if (UTTypeConformsTo(flavorType, CFSTR("public.file-url")))
|
|
||||||
{
|
|
||||||
CFDataRef flavorData;
|
|
||||||
|
|
||||||
err = PasteboardCopyItemFlavorData(pasteboard, itemID, flavorType, &flavorData);
|
|
||||||
if (err == noErr)
|
|
||||||
{
|
|
||||||
CFIndex dataSize;
|
|
||||||
UInt8 *data;
|
|
||||||
|
|
||||||
dataSize = CFDataGetLength(flavorData);
|
|
||||||
data = (UInt8 *) malloc(dataSize);
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
CFDataGetBytes(flavorData, CFRangeMake(0, dataSize), data);
|
|
||||||
|
|
||||||
HIViewRef ctl;
|
|
||||||
HIViewID cid;
|
|
||||||
CFStringRef str;
|
|
||||||
CFURLRef url;
|
|
||||||
|
|
||||||
GetControlID(view, &cid);
|
|
||||||
cid.signature = 'MNAM';
|
|
||||||
HIViewFindByID(view, cid, &ctl);
|
|
||||||
|
|
||||||
url = CFURLCreateWithBytes(kCFAllocatorDefault, data, dataSize, kCFStringEncodingUTF8, NULL);
|
|
||||||
str = CFURLCopyLastPathComponent(url);
|
|
||||||
SetStaticTextCFString(ctl, str, true);
|
|
||||||
CFRelease(str);
|
|
||||||
str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
|
||||||
if (multiCartPath[cid.id])
|
|
||||||
CFRelease(multiCartPath[cid.id]);
|
|
||||||
multiCartPath[cid.id] = str;
|
|
||||||
CFRelease(url);
|
|
||||||
|
|
||||||
result = noErr;
|
|
||||||
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(flavorData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
|
|
@ -0,0 +1,539 @@
|
||||||
|
/*****************************************************************************\
|
||||||
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||||
|
This file is licensed under the Snes9x License.
|
||||||
|
For further information, consult the LICENSE file in the root directory.
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************************
|
||||||
|
SNES9X for Mac OS (c) Copyright John Stiles
|
||||||
|
|
||||||
|
Snes9x for Mac OS X
|
||||||
|
|
||||||
|
(c) Copyright 2001 - 2011 zones
|
||||||
|
(c) Copyright 2002 - 2005 107
|
||||||
|
(c) Copyright 2002 PB1400c
|
||||||
|
(c) Copyright 2004 Alexander and Sander
|
||||||
|
(c) Copyright 2004 - 2005 Steven Seeger
|
||||||
|
(c) Copyright 2005 Ryan Vogt
|
||||||
|
***********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
|
#include "mac-prefix.h"
|
||||||
|
#include "mac-cart.h"
|
||||||
|
#include "mac-dialog.h"
|
||||||
|
#include "mac-os.h"
|
||||||
|
#include "mac-multicart.h"
|
||||||
|
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
|
#define truncEnd 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static OSStatus MultiCartEventHandler (EventHandlerCallRef, EventRef, void *);
|
||||||
|
static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef, EventRef, void *);
|
||||||
|
|
||||||
|
static int multiCartDragHilite;
|
||||||
|
static Boolean multiCartDialogResult;
|
||||||
|
|
||||||
|
void InitMultiCart (void)
|
||||||
|
{
|
||||||
|
CFStringRef keyRef, pathRef;
|
||||||
|
char key[32];
|
||||||
|
|
||||||
|
multiCartPath[0] = multiCartPath[1] = NULL;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
sprintf(key, "MultiCartPath_%02d", i);
|
||||||
|
keyRef = CFStringCreateWithCString(kCFAllocatorDefault, key, CFStringGetSystemEncoding());
|
||||||
|
if (keyRef)
|
||||||
|
{
|
||||||
|
pathRef = (CFStringRef) CFPreferencesCopyAppValue(keyRef, kCFPreferencesCurrentApplication);
|
||||||
|
if (pathRef)
|
||||||
|
multiCartPath[i] = pathRef;
|
||||||
|
|
||||||
|
CFRelease(keyRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeinitMultiCart (void)
|
||||||
|
{
|
||||||
|
CFStringRef keyRef;
|
||||||
|
char key[32];
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
sprintf(key, "MultiCartPath_%02d", i);
|
||||||
|
keyRef = CFStringCreateWithCString(kCFAllocatorDefault, key, CFStringGetSystemEncoding());
|
||||||
|
if (keyRef)
|
||||||
|
{
|
||||||
|
if (multiCartPath[i])
|
||||||
|
{
|
||||||
|
CFPreferencesSetAppValue(keyRef, multiCartPath[i], kCFPreferencesCurrentApplication);
|
||||||
|
CFRelease(multiCartPath[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CFPreferencesSetAppValue(keyRef, NULL, kCFPreferencesCurrentApplication);
|
||||||
|
|
||||||
|
CFRelease(keyRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean MultiCartDialog (void)
|
||||||
|
{
|
||||||
|
// OSStatus err;
|
||||||
|
// IBNibRef nibRef;
|
||||||
|
//
|
||||||
|
// multiCartDragHilite = -1;
|
||||||
|
// multiCartDialogResult = false;
|
||||||
|
//
|
||||||
|
// err = CreateNibReference(kMacS9XCFString, &nibRef);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// WindowRef window;
|
||||||
|
//
|
||||||
|
// err = CreateWindowFromNib(nibRef, CFSTR("MultiCart"), &window);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// static int index[2] = { 0, 1 };
|
||||||
|
//
|
||||||
|
// EventHandlerRef wRef, cRef[2];
|
||||||
|
// EventHandlerUPP wUPP, cUPP[2];
|
||||||
|
// EventTypeSpec wEvent[] = { { kEventClassCommand, kEventCommandProcess },
|
||||||
|
// { kEventClassCommand, kEventCommandUpdateStatus } },
|
||||||
|
// cEvent[] = { { kEventClassControl, kEventControlDraw },
|
||||||
|
// { kEventClassControl, kEventControlDragEnter },
|
||||||
|
// { kEventClassControl, kEventControlDragWithin },
|
||||||
|
// { kEventClassControl, kEventControlDragLeave },
|
||||||
|
// { kEventClassControl, kEventControlDragReceive } };
|
||||||
|
// HIViewRef ctl, root, pane[2];
|
||||||
|
// HIViewID cid;
|
||||||
|
//
|
||||||
|
// root = HIViewGetRoot(window);
|
||||||
|
//
|
||||||
|
// wUPP = NewEventHandlerUPP(MultiCartEventHandler);
|
||||||
|
// err = InstallWindowEventHandler(window, wUPP, GetEventTypeCount(wEvent), wEvent, (void *) window, &wRef);
|
||||||
|
// err = SetAutomaticControlDragTrackingEnabledForWindow(window, true);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 2; i++)
|
||||||
|
// {
|
||||||
|
// cid.id = i;
|
||||||
|
//
|
||||||
|
// cid.signature = 'MPan';
|
||||||
|
// HIViewFindByID(root, cid, &pane[i]);
|
||||||
|
// cUPP[i] = NewEventHandlerUPP(MultiCartPaneEventHandler);
|
||||||
|
// err = InstallControlEventHandler(pane[i], cUPP[i], GetEventTypeCount(cEvent), cEvent, (void *) &index[i], &cRef[i]);
|
||||||
|
// err = SetControlDragTrackingEnabled(pane[i], true);
|
||||||
|
//
|
||||||
|
// cid.signature = 'MNAM';
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// SetStaticTextTrunc(ctl, truncEnd, false);
|
||||||
|
// if (multiCartPath[i])
|
||||||
|
// {
|
||||||
|
// CFStringRef str;
|
||||||
|
// CFURLRef url;
|
||||||
|
//
|
||||||
|
// url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, multiCartPath[i], kCFURLPOSIXPathStyle, false);
|
||||||
|
// str = CFURLCopyLastPathComponent(url);
|
||||||
|
// SetStaticTextCFString(ctl, str, false);
|
||||||
|
// CFRelease(str);
|
||||||
|
// CFRelease(url);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// SetStaticTextCFString(ctl, CFSTR(""), false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MoveWindowPosition(window, kWindowMultiCart, false);
|
||||||
|
// ShowWindow(window);
|
||||||
|
// err = RunAppModalLoopForWindow(window);
|
||||||
|
// HideWindow(window);
|
||||||
|
// SaveWindowPosition(window, kWindowMultiCart);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 2; i++)
|
||||||
|
// {
|
||||||
|
// err = RemoveEventHandler(cRef[i]);
|
||||||
|
// DisposeEventHandlerUPP(cUPP[i]);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// err = RemoveEventHandler(wRef);
|
||||||
|
// DisposeEventHandlerUPP(wUPP);
|
||||||
|
//
|
||||||
|
// CFRelease(window);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// DisposeNibReference(nibRef);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (multiCartDialogResult);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSStatus MultiCartEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
|
{
|
||||||
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
|
// WindowRef window = (WindowRef) inUserData;
|
||||||
|
// static int index = -1;
|
||||||
|
//
|
||||||
|
// switch (GetEventClass(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventClassCommand:
|
||||||
|
// {
|
||||||
|
// switch (GetEventKind(inEvent))
|
||||||
|
// {
|
||||||
|
// HICommand tHICommand;
|
||||||
|
//
|
||||||
|
// case kEventCommandUpdateStatus:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
|
// if (err == noErr && tHICommand.commandID == 'clos')
|
||||||
|
// {
|
||||||
|
// UpdateMenuCommandStatus(false);
|
||||||
|
// result = noErr;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case kEventCommandProcess:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// HIViewRef ctl, root;
|
||||||
|
// HIViewID cid;
|
||||||
|
// FSRef ref;
|
||||||
|
// bool8 r;
|
||||||
|
//
|
||||||
|
// root = HIViewGetRoot(window);
|
||||||
|
//
|
||||||
|
// switch (tHICommand.commandID)
|
||||||
|
// {
|
||||||
|
// case 'Cho0':
|
||||||
|
// case 'Cho1':
|
||||||
|
// {
|
||||||
|
// index = (tHICommand.commandID & 0xFF) - '0';
|
||||||
|
// // r = NavBeginOpenROMImageSheet(window, NULL);
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case 'NvDn':
|
||||||
|
// {
|
||||||
|
// r = NavEndOpenROMImageSheet(&ref);
|
||||||
|
// if (r)
|
||||||
|
// {
|
||||||
|
// CFStringRef str;
|
||||||
|
// CFURLRef url;
|
||||||
|
//
|
||||||
|
// url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref);
|
||||||
|
// str = CFURLCopyLastPathComponent(url);
|
||||||
|
// cid.signature = 'MNAM';
|
||||||
|
// cid.id = index;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// SetStaticTextCFString(ctl, str, true);
|
||||||
|
// CFRelease(str);
|
||||||
|
// str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
|
// if (multiCartPath[index])
|
||||||
|
// CFRelease(multiCartPath[index]);
|
||||||
|
// multiCartPath[index] = str;
|
||||||
|
// CFRelease(url);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// index = -1;
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case 'Cle0':
|
||||||
|
// case 'Cle1':
|
||||||
|
// {
|
||||||
|
// index = (tHICommand.commandID & 0xFF) - '0';
|
||||||
|
// cid.signature = 'MNAM';
|
||||||
|
// cid.id = index;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
// SetStaticTextCFString(ctl, CFSTR(""), true);
|
||||||
|
// if (multiCartPath[index])
|
||||||
|
// {
|
||||||
|
// CFRelease(multiCartPath[index]);
|
||||||
|
// multiCartPath[index] = NULL;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// index = -1;
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case 'SWAP':
|
||||||
|
// {
|
||||||
|
// CFStringRef str;
|
||||||
|
// CFURLRef url;
|
||||||
|
//
|
||||||
|
// str = multiCartPath[0];
|
||||||
|
// multiCartPath[0] = multiCartPath[1];
|
||||||
|
// multiCartPath[1] = str;
|
||||||
|
//
|
||||||
|
// cid.signature = 'MNAM';
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 2; i++)
|
||||||
|
// {
|
||||||
|
// cid.id = i;
|
||||||
|
// HIViewFindByID(root, cid, &ctl);
|
||||||
|
//
|
||||||
|
// if (multiCartPath[i])
|
||||||
|
// {
|
||||||
|
// url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, multiCartPath[i], kCFURLPOSIXPathStyle, false);
|
||||||
|
// str = CFURLCopyLastPathComponent(url);
|
||||||
|
// SetStaticTextCFString(ctl, str, true);
|
||||||
|
// CFRelease(str);
|
||||||
|
// CFRelease(url);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// SetStaticTextCFString(ctl, CFSTR(""), true);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case 'ok ':
|
||||||
|
// {
|
||||||
|
// QuitAppModalLoopForWindow(window);
|
||||||
|
// multiCartDialogResult = true;
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case 'not!':
|
||||||
|
// {
|
||||||
|
// QuitAppModalLoopForWindow(window);
|
||||||
|
// multiCartDialogResult = false;
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (result);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
|
||||||
|
{
|
||||||
|
// OSStatus err, result = eventNotHandledErr;
|
||||||
|
// HIViewRef view;
|
||||||
|
// DragRef drag;
|
||||||
|
// PasteboardRef pasteboard;
|
||||||
|
// PasteboardItemID itemID;
|
||||||
|
// CFArrayRef array;
|
||||||
|
// CFStringRef flavorType;
|
||||||
|
// CFIndex numFlavors;
|
||||||
|
// ItemCount numItems;
|
||||||
|
// int index = *((int *) inUserData);
|
||||||
|
//
|
||||||
|
// switch (GetEventClass(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventClassControl:
|
||||||
|
// {
|
||||||
|
// switch (GetEventKind(inEvent))
|
||||||
|
// {
|
||||||
|
// case kEventControlDraw:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// CGContextRef ctx;
|
||||||
|
//
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &ctx);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// HIThemeFrameDrawInfo info;
|
||||||
|
// HIRect bounds, frame;
|
||||||
|
//
|
||||||
|
// HIViewGetBounds(view, &bounds);
|
||||||
|
//
|
||||||
|
// CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
// CGContextFillRect(ctx, bounds);
|
||||||
|
//
|
||||||
|
// info.version = 0;
|
||||||
|
// info.kind = kHIThemeFrameTextFieldSquare;
|
||||||
|
// info.state = kThemeStateInactive;
|
||||||
|
// info.isFocused = false;
|
||||||
|
// err = HIThemeDrawFrame(&bounds, &info, ctx, kHIThemeOrientationNormal);
|
||||||
|
//
|
||||||
|
// if (multiCartDragHilite == index && systemVersion >= 0x1040)
|
||||||
|
// {
|
||||||
|
// err = HIThemeSetStroke(kThemeBrushDragHilite, NULL, ctx, kHIThemeOrientationNormal);
|
||||||
|
// frame = CGRectInset(bounds, 1, 1);
|
||||||
|
// CGContextBeginPath(ctx);
|
||||||
|
// CGContextAddRect(ctx, frame);
|
||||||
|
// CGContextStrokePath(ctx);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case kEventControlDragEnter:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDragRef, typeDragRef, NULL, sizeof(DragRef), NULL, &drag);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = GetDragPasteboard(drag, &pasteboard);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = PasteboardGetItemCount(pasteboard, &numItems);
|
||||||
|
// if (err == noErr && numItems == 1)
|
||||||
|
// {
|
||||||
|
// err = PasteboardGetItemIdentifier(pasteboard, 1, &itemID);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = PasteboardCopyItemFlavors(pasteboard, itemID, &array);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// numFlavors = CFArrayGetCount(array);
|
||||||
|
// for (CFIndex i = 0; i < numFlavors; i++)
|
||||||
|
// {
|
||||||
|
// flavorType = (CFStringRef) CFArrayGetValueAtIndex(array, i);
|
||||||
|
// if (UTTypeConformsTo(flavorType, CFSTR("public.file-url")))
|
||||||
|
// {
|
||||||
|
// Boolean accept = true;
|
||||||
|
//
|
||||||
|
// err = SetEventParameter(inEvent, kEventParamControlWouldAcceptDrop, typeBoolean, sizeof(Boolean), &accept);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// multiCartDragHilite = index;
|
||||||
|
// HIViewSetNeedsDisplay(view, true);
|
||||||
|
// result = noErr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// CFRelease(array);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case kEventControlDragWithin:
|
||||||
|
// {
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case kEventControlDragLeave:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// multiCartDragHilite = -1;
|
||||||
|
// HIViewSetNeedsDisplay(view, true);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case kEventControlDragReceive:
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &view);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = GetEventParameter(inEvent, kEventParamDragRef, typeDragRef, NULL, sizeof(DragRef), NULL, &drag);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// multiCartDragHilite = -1;
|
||||||
|
// HIViewSetNeedsDisplay(view, true);
|
||||||
|
//
|
||||||
|
// err = GetDragPasteboard(drag, &pasteboard);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = PasteboardGetItemIdentifier(pasteboard, 1, &itemID);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// err = PasteboardCopyItemFlavors(pasteboard, itemID, &array);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// numFlavors = CFArrayGetCount(array);
|
||||||
|
// for (CFIndex i = 0; i < numFlavors; i++)
|
||||||
|
// {
|
||||||
|
// flavorType = (CFStringRef) CFArrayGetValueAtIndex(array, i);
|
||||||
|
// if (UTTypeConformsTo(flavorType, CFSTR("public.file-url")))
|
||||||
|
// {
|
||||||
|
// CFDataRef flavorData;
|
||||||
|
//
|
||||||
|
// err = PasteboardCopyItemFlavorData(pasteboard, itemID, flavorType, &flavorData);
|
||||||
|
// if (err == noErr)
|
||||||
|
// {
|
||||||
|
// CFIndex dataSize;
|
||||||
|
// UInt8 *data;
|
||||||
|
//
|
||||||
|
// dataSize = CFDataGetLength(flavorData);
|
||||||
|
// data = (UInt8 *) malloc(dataSize);
|
||||||
|
// if (data)
|
||||||
|
// {
|
||||||
|
// CFDataGetBytes(flavorData, CFRangeMake(0, dataSize), data);
|
||||||
|
//
|
||||||
|
// HIViewRef ctl;
|
||||||
|
// HIViewID cid;
|
||||||
|
// CFStringRef str;
|
||||||
|
// CFURLRef url;
|
||||||
|
//
|
||||||
|
// GetControlID(view, &cid);
|
||||||
|
// cid.signature = 'MNAM';
|
||||||
|
// HIViewFindByID(view, cid, &ctl);
|
||||||
|
//
|
||||||
|
// url = CFURLCreateWithBytes(kCFAllocatorDefault, data, dataSize, kCFStringEncodingUTF8, NULL);
|
||||||
|
// str = CFURLCopyLastPathComponent(url);
|
||||||
|
// SetStaticTextCFString(ctl, str, true);
|
||||||
|
// CFRelease(str);
|
||||||
|
// str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
|
// if (multiCartPath[cid.id])
|
||||||
|
// CFRelease(multiCartPath[cid.id]);
|
||||||
|
// multiCartPath[cid.id] = str;
|
||||||
|
// CFRelease(url);
|
||||||
|
//
|
||||||
|
// result = noErr;
|
||||||
|
//
|
||||||
|
// free(data);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// CFRelease(flavorData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// CFRelease(array);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return (result);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -122,7 +122,7 @@ static void * SoundTask (void *);
|
||||||
MacStartSound();
|
MacStartSound();
|
||||||
pthread_create(&mbxThread, NULL, SoundTask, NULL);
|
pthread_create(&mbxThread, NULL, SoundTask, NULL);
|
||||||
|
|
||||||
timer = [[NSTimer scheduledTimerWithTimeInterval: (2.0 / (double) Memory.ROMFramesPerSecond) target: self selector: @selector(updateIndicator:) userInfo: nil repeats: YES] retain];
|
timer = [NSTimer scheduledTimerWithTimeInterval: (2.0 / (double) Memory.ROMFramesPerSecond) target: self selector: @selector(updateIndicator:) userInfo: nil repeats: YES];
|
||||||
|
|
||||||
return (self);
|
return (self);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ static void * SoundTask (void *);
|
||||||
BOOL r;
|
BOOL r;
|
||||||
|
|
||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
[timer release];
|
timer = nil;
|
||||||
|
|
||||||
showIndicator = false;
|
showIndicator = false;
|
||||||
|
|
||||||
|
@ -159,10 +159,6 @@ static void * SoundTask (void *);
|
||||||
SPCPlayDefrost();
|
SPCPlayDefrost();
|
||||||
else
|
else
|
||||||
MusicBoxForceDefrost();
|
MusicBoxForceDefrost();
|
||||||
|
|
||||||
[window release];
|
|
||||||
|
|
||||||
[super dealloc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow *) window
|
- (NSWindow *) window
|
||||||
|
@ -268,7 +264,7 @@ static void * SoundTask (void *);
|
||||||
const float length[] = { 1.0f, 1.0f };
|
const float length[] = { 1.0f, 1.0f };
|
||||||
|
|
||||||
CGContextSetLineWidth(mboxctx, mbxBarWidth);
|
CGContextSetLineWidth(mboxctx, mbxBarWidth);
|
||||||
CGContextSetLineDash(mboxctx, 0, length, 2);
|
//CGContextSetLineDash(mboxctx, 0, length, 2);
|
||||||
CGContextSetLineJoin(mboxctx, kCGLineJoinMiter);
|
CGContextSetLineJoin(mboxctx, kCGLineJoinMiter);
|
||||||
|
|
||||||
CGContextBeginPath(mboxctx);
|
CGContextBeginPath(mboxctx);
|
||||||
|
@ -457,21 +453,14 @@ static void SPCPlayDefrost (void)
|
||||||
void MusicBoxDialog (void)
|
void MusicBoxDialog (void)
|
||||||
{
|
{
|
||||||
MusicBoxController *controller;
|
MusicBoxController *controller;
|
||||||
NSAutoreleasePool *pool;
|
|
||||||
|
|
||||||
if (!cartOpen)
|
if (!cartOpen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
controller = [[MusicBoxController alloc] init];
|
controller = [[MusicBoxController alloc] init];
|
||||||
[pool release];
|
|
||||||
|
|
||||||
if (!controller)
|
if (!controller)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[NSApp runModalForWindow: [controller window]];
|
[NSApp runModalForWindow: [controller window]];
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
[controller release];
|
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,6 @@ extern int macFrameSkip;
|
||||||
extern int32 skipFrames;
|
extern int32 skipFrames;
|
||||||
extern int64 lastFrame;
|
extern int64 lastFrame;
|
||||||
extern unsigned long spcFileCount, pngFileCount;
|
extern unsigned long spcFileCount, pngFileCount;
|
||||||
extern SInt32 systemVersion;
|
|
||||||
extern bool8 finished, cartOpen,
|
extern bool8 finished, cartOpen,
|
||||||
autofire, hidExist, directDisplay;
|
autofire, hidExist, directDisplay;
|
||||||
extern bool8 fullscreen, autoRes,
|
extern bool8 fullscreen, autoRes,
|
||||||
|
@ -138,7 +137,7 @@ extern uint32 macSoundBuffer_ms, macSoundInterval_ms;
|
||||||
extern bool8 macSoundLagEnable;
|
extern bool8 macSoundLagEnable;
|
||||||
extern uint16 aueffect;
|
extern uint16 aueffect;
|
||||||
extern uint8 saveInROMFolder;
|
extern uint8 saveInROMFolder;
|
||||||
extern CFStringRef saveFolderPath;
|
extern NSString *saveFolderPath;
|
||||||
extern int macCurvatureWarp, macAspectRatio;
|
extern int macCurvatureWarp, macAspectRatio;
|
||||||
extern int macFastForwardRate, macFrameAdvanceRate;
|
extern int macFastForwardRate, macFrameAdvanceRate;
|
||||||
extern int inactiveMode;
|
extern int inactiveMode;
|
||||||
|
@ -159,18 +158,15 @@ extern CFStringRef multiCartPath[2];
|
||||||
extern IconRef macIconRef[118];
|
extern IconRef macIconRef[118];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void InitGameWindow (void);
|
void AddRecentItem (NSURL *);
|
||||||
void DeinitGameWindow (void);
|
|
||||||
void UpdateGameWindow (void);
|
|
||||||
void AddRecentItem (FSRef *);
|
|
||||||
void BuildRecentMenu (void);
|
|
||||||
void AdjustMenus (void);
|
void AdjustMenus (void);
|
||||||
void UpdateMenuCommandStatus (Boolean);
|
void UpdateMenuCommandStatus (Boolean);
|
||||||
void ApplyNSRTHeaderControllers (void);
|
void ApplyNSRTHeaderControllers (void);
|
||||||
void QuitWithFatalError (OSStatus, const char *);
|
void QuitWithFatalError (NSString *);
|
||||||
void ChangeInputDevice (void);
|
void ChangeInputDevice (void);
|
||||||
void GetGameScreenPointer (int16 *, int16 *, bool);
|
void GetGameScreenPointer (int16 *, int16 *, bool);
|
||||||
void PostQueueToSubEventLoop (void);
|
void PostQueueToSubEventLoop (void);
|
||||||
int PromptFreezeDefrost (Boolean);
|
int PromptFreezeDefrost (Boolean);
|
||||||
|
uint64 GetMicroseconds();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
5360
macosx/mac-os.mm
5360
macosx/mac-os.mm
File diff suppressed because it is too large
Load Diff
1587
macosx/mac-prefs.cpp
1587
macosx/mac-prefs.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,6 @@
|
||||||
#include "mac-cheatfinder.h"
|
#include "mac-cheatfinder.h"
|
||||||
#include "mac-coreimage.h"
|
#include "mac-coreimage.h"
|
||||||
#include "mac-os.h"
|
#include "mac-os.h"
|
||||||
#include "mac-quicktime.h"
|
|
||||||
#include "mac-screenshot.h"
|
#include "mac-screenshot.h"
|
||||||
#include "mac-render.h"
|
#include "mac-render.h"
|
||||||
|
|
||||||
|
@ -197,13 +196,13 @@ void InitGraphics (void)
|
||||||
GFX.Screen = gfxScreen[0];
|
GFX.Screen = gfxScreen[0];
|
||||||
|
|
||||||
if (!snesScreenA || !snesScreenB || !blitGLBuffer)
|
if (!snesScreenA || !snesScreenB || !blitGLBuffer)
|
||||||
QuitWithFatalError(0, "render 01");
|
QuitWithFatalError(@"render 01");
|
||||||
|
|
||||||
if (!S9xBlitFilterInit() |
|
if (!S9xBlitFilterInit() |
|
||||||
!S9xBlit2xSaIFilterInit() |
|
!S9xBlit2xSaIFilterInit() |
|
||||||
!S9xBlitHQ2xFilterInit() |
|
!S9xBlitHQ2xFilterInit() |
|
||||||
!S9xBlitNTSCFilterInit())
|
!S9xBlitNTSCFilterInit())
|
||||||
QuitWithFatalError(0, "render 02");
|
QuitWithFatalError(@"render 02");
|
||||||
|
|
||||||
switch (videoMode)
|
switch (videoMode)
|
||||||
{
|
{
|
||||||
|
@ -406,8 +405,6 @@ static void SetBestDisplayMode (int width, int height)
|
||||||
|
|
||||||
static void S9xInitFullScreen (void)
|
static void S9xInitFullScreen (void)
|
||||||
{
|
{
|
||||||
DeinitGameWindow();
|
|
||||||
|
|
||||||
size_t width, height;
|
size_t width, height;
|
||||||
|
|
||||||
width = autoRes ? 640 : CGDisplayPixelsWide(gGameDisplayID);
|
width = autoRes ? 640 : CGDisplayPixelsWide(gGameDisplayID);
|
||||||
|
@ -485,13 +482,13 @@ static void S9xInitWindowMode (void)
|
||||||
SetBestDisplayMode(width, height);
|
SetBestDisplayMode(width, height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InitGameWindow();
|
// InitGameWindow();
|
||||||
ShowWindow(gWindow);
|
// ShowWindow(gWindow);
|
||||||
|
//
|
||||||
|
// GetWindowBounds(gWindow, kWindowContentRgn, &rct);
|
||||||
|
// gWindowRect = CGRectMake((float) rct.left, (float) rct.top, (float) (rct.right - rct.left), (float) (rct.bottom - rct.top));
|
||||||
|
|
||||||
GetWindowBounds(gWindow, kWindowContentRgn, &rct);
|
// UpdateGameWindow();
|
||||||
gWindowRect = CGRectMake((float) rct.left, (float) rct.top, (float) (rct.right - rct.left), (float) (rct.bottom - rct.top));
|
|
||||||
|
|
||||||
UpdateGameWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void S9xDeinitWindowMode (void)
|
static void S9xDeinitWindowMode (void)
|
||||||
|
@ -505,7 +502,7 @@ static void S9xDeinitWindowMode (void)
|
||||||
CGDisplayModeRelease(oldDisplayModeRef);
|
CGDisplayModeRelease(oldDisplayModeRef);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UpdateGameWindow();
|
// UpdateGameWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void S9xInitOpenGLFullScreen (void)
|
static void S9xInitOpenGLFullScreen (void)
|
||||||
|
@ -565,12 +562,7 @@ static void S9xInitOpenGLWindowMode (void)
|
||||||
aglpix = aglChoosePixelFormat(NULL, 0, attribs);
|
aglpix = aglChoosePixelFormat(NULL, 0, attribs);
|
||||||
agContext = aglCreateContext(aglpix, NULL);
|
agContext = aglCreateContext(aglpix, NULL);
|
||||||
|
|
||||||
if (systemVersion >= 0x1050)
|
|
||||||
aglSetWindowRef(agContext, gWindow);
|
aglSetWindowRef(agContext, gWindow);
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
aglSetDrawable(agContext, GetWindowPort(gWindow));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
agSwapInterval = vsync ? 1 : 0;
|
agSwapInterval = vsync ? 1 : 0;
|
||||||
if (extraOptions.benchmark)
|
if (extraOptions.benchmark)
|
||||||
|
@ -578,23 +570,15 @@ static void S9xInitOpenGLWindowMode (void)
|
||||||
aglSetInteger(agContext, AGL_SWAP_INTERVAL, &agSwapInterval);
|
aglSetInteger(agContext, AGL_SWAP_INTERVAL, &agSwapInterval);
|
||||||
aglSetCurrentContext(agContext);
|
aglSetCurrentContext(agContext);
|
||||||
|
|
||||||
if (systemVersion >= 0x1040)
|
|
||||||
{
|
|
||||||
aglGetCGLPixelFormat(aglpix, (void **) &cglpix);
|
aglGetCGLPixelFormat(aglpix, (void **) &cglpix);
|
||||||
aglGetCGLContext(agContext, (void **) &glContext);
|
aglGetCGLContext(agContext, (void **) &glContext);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void S9xDeinitOpenGLWindowMode (void)
|
static void S9xDeinitOpenGLWindowMode (void)
|
||||||
{
|
{
|
||||||
if (agContext)
|
if (agContext)
|
||||||
{
|
{
|
||||||
if (systemVersion >= 0x1050)
|
|
||||||
aglSetWindowRef(agContext, NULL);
|
aglSetWindowRef(agContext, NULL);
|
||||||
#ifdef MAC_TIGER_PANTHER_SUPPORT
|
|
||||||
else
|
|
||||||
aglSetDrawable(agContext, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
aglSetCurrentContext(NULL);
|
aglSetCurrentContext(NULL);
|
||||||
aglDestroyContext(agContext);
|
aglDestroyContext(agContext);
|
|
@ -118,7 +118,7 @@ CGImageRef CreateGameScreenCGImage (void)
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
image = CGImageCreate(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, 5, 16, rowbytes, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrder16Host : 0), prov, NULL, 1, kCGRenderingIntentDefault);
|
image = CGImageCreate(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, 5, 16, rowbytes, color, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder16Host, prov, NULL, 1, kCGRenderingIntentDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ CGImageRef CreateBlitScreenCGImage (int width, int height, int rowbytes, uint8 *
|
||||||
color = CGColorSpaceCreateDeviceRGB();
|
color = CGColorSpaceCreateDeviceRGB();
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
image = CGImageCreate(width, height, 5, 16, rowbytes, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrder16Host : 0), prov, NULL, 1, kCGRenderingIntentDefault);
|
image = CGImageCreate(width, height, 5, 16, rowbytes, color, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder16Host, prov, NULL, 1, kCGRenderingIntentDefault);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ void SNES9X_Reset (void);
|
||||||
void SNES9X_SoftReset (void);
|
void SNES9X_SoftReset (void);
|
||||||
void SNES9X_Quit (void);
|
void SNES9X_Quit (void);
|
||||||
void SNES9X_InitSound (void);
|
void SNES9X_InitSound (void);
|
||||||
bool8 SNES9X_OpenCart (FSRef *);
|
bool8 SNES9X_OpenCart (NSURL *);
|
||||||
bool8 SNES9X_OpenMultiCart (void);
|
bool8 SNES9X_OpenMultiCart (void);
|
||||||
bool8 SNES9X_Freeze (void);
|
bool8 SNES9X_Freeze (void);
|
||||||
bool8 SNES9X_FreezeTo (void);
|
bool8 SNES9X_FreezeTo (void);
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "mac-file.h"
|
#include "mac-file.h"
|
||||||
#include "mac-multicart.h"
|
#include "mac-multicart.h"
|
||||||
#include "mac-os.h"
|
#include "mac-os.h"
|
||||||
#include "mac-quicktime.h"
|
|
||||||
#include "mac-screenshot.h"
|
#include "mac-screenshot.h"
|
||||||
#include "mac-stringtools.h"
|
#include "mac-stringtools.h"
|
||||||
#include "mac-snes9x.h"
|
#include "mac-snes9x.h"
|
||||||
|
@ -51,13 +50,10 @@ void SNES9X_Go (void)
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 SNES9X_OpenCart (FSRef *inRef)
|
bool8 SNES9X_OpenCart (NSURL *inRef)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
NSURL *cartRef;
|
||||||
FSRef cartRef;
|
const char *filename = inRef.lastPathComponent.UTF8String;
|
||||||
char filename[PATH_MAX + 1];
|
|
||||||
|
|
||||||
DeinitGameWindow();
|
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
|
@ -70,18 +66,19 @@ bool8 SNES9X_OpenCart (FSRef *inRef)
|
||||||
|
|
||||||
if (!inRef)
|
if (!inRef)
|
||||||
{
|
{
|
||||||
if (!NavOpenROMImage(&cartRef))
|
cartRef = NavOpenROMImage();
|
||||||
|
if (!cartRef)
|
||||||
{
|
{
|
||||||
cartOpen = false;
|
cartOpen = false;
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cartRef = *inRef;
|
cartRef = inRef;
|
||||||
|
|
||||||
spcFileCount = pngFileCount = 0;
|
spcFileCount = pngFileCount = 0;
|
||||||
|
|
||||||
CheckSaveFolder(&cartRef);
|
CheckSaveFolder(cartRef);
|
||||||
|
|
||||||
Settings.ForceLoROM = (romDetect == kLoROMForce );
|
Settings.ForceLoROM = (romDetect == kLoROMForce );
|
||||||
Settings.ForceHiROM = (romDetect == kHiROMForce );
|
Settings.ForceHiROM = (romDetect == kHiROMForce );
|
||||||
|
@ -99,8 +96,6 @@ bool8 SNES9X_OpenCart (FSRef *inRef)
|
||||||
|
|
||||||
S9xResetSaveTimer(true);
|
S9xResetSaveTimer(true);
|
||||||
|
|
||||||
err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX);
|
|
||||||
|
|
||||||
SNES9X_InitSound();
|
SNES9X_InitSound();
|
||||||
|
|
||||||
if (Memory.LoadROM(filename))
|
if (Memory.LoadROM(filename))
|
||||||
|
@ -111,8 +106,8 @@ bool8 SNES9X_OpenCart (FSRef *inRef)
|
||||||
|
|
||||||
ChangeTypeAndCreator(filename, 'CART', '~9X~');
|
ChangeTypeAndCreator(filename, 'CART', '~9X~');
|
||||||
|
|
||||||
AddRecentItem(&cartRef);
|
AddRecentItem(cartRef);
|
||||||
BuildRecentMenu();
|
//BuildRecentMenu();
|
||||||
|
|
||||||
ApplyNSRTHeaderControllers();
|
ApplyNSRTHeaderControllers();
|
||||||
|
|
||||||
|
@ -134,8 +129,6 @@ bool8 SNES9X_OpenMultiCart (void)
|
||||||
Boolean r;
|
Boolean r;
|
||||||
char cart[2][PATH_MAX + 1];
|
char cart[2][PATH_MAX + 1];
|
||||||
|
|
||||||
DeinitGameWindow();
|
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
SNES9X_SaveSRAM();
|
SNES9X_SaveSRAM();
|
||||||
|
@ -306,12 +299,12 @@ bool8 SNES9X_Defrost (void)
|
||||||
|
|
||||||
bool8 SNES9X_FreezeTo (void)
|
bool8 SNES9X_FreezeTo (void)
|
||||||
{
|
{
|
||||||
char filename[PATH_MAX + 1];
|
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
if (NavFreezeTo(filename))
|
NSURL *url = NavFreezeTo();
|
||||||
|
if (url != nil)
|
||||||
{
|
{
|
||||||
|
const char *filename = url.lastPathComponent.UTF8String;
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
|
||||||
S9xFreezeGame(filename);
|
S9xFreezeGame(filename);
|
||||||
|
@ -331,8 +324,10 @@ bool8 SNES9X_DefrostFrom (void)
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
if (NavDefrostFrom(filename))
|
NSURL *url = NavDefrostFrom();
|
||||||
|
if (url != nil)
|
||||||
{
|
{
|
||||||
|
const char *filename = url.lastPathComponent.UTF8String;
|
||||||
S9xUnfreezeGame(filename);
|
S9xUnfreezeGame(filename);
|
||||||
|
|
||||||
SNES9X_Go();
|
SNES9X_Go();
|
||||||
|
@ -346,12 +341,12 @@ bool8 SNES9X_DefrostFrom (void)
|
||||||
|
|
||||||
bool8 SNES9X_RecordMovie (void)
|
bool8 SNES9X_RecordMovie (void)
|
||||||
{
|
{
|
||||||
char filename[PATH_MAX + 1];
|
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
if (NavRecordMovieTo(filename))
|
NSURL *url = NavRecordMovieTo();
|
||||||
|
if (url != nil)
|
||||||
{
|
{
|
||||||
|
const char *filename = url.lastPathComponent.UTF8String;
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
|
@ -392,8 +387,10 @@ bool8 SNES9X_PlayMovie (void)
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
if (NavPlayMovieFrom(filename))
|
NSURL *url = NavPlayMovieFrom();
|
||||||
|
if (url != nil)
|
||||||
{
|
{
|
||||||
|
const char *filename = url.lastPathComponent.UTF8String;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = S9xMovieOpen(filename, macPlayFlag & 1);
|
r = S9xMovieOpen(filename, macPlayFlag & 1);
|
||||||
|
@ -415,9 +412,10 @@ bool8 SNES9X_QTMovieRecord (void)
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
if (NavQTMovieRecordTo(filename))
|
NSURL *url = NavQTMovieRecordTo();
|
||||||
|
if (url != nil)
|
||||||
{
|
{
|
||||||
MacQTStartRecording(filename);
|
const char *filename = url.lastPathComponent.UTF8String;
|
||||||
macQTRecord = true;
|
macQTRecord = true;
|
||||||
SNES9X_Go();
|
SNES9X_Go();
|
||||||
|
|
||||||
|
@ -432,8 +430,6 @@ bool8 SNES9X_QTMovieRecord (void)
|
||||||
|
|
||||||
void SNES9X_Quit (void)
|
void SNES9X_Quit (void)
|
||||||
{
|
{
|
||||||
DeinitGameWindow();
|
|
||||||
|
|
||||||
if (cartOpen)
|
if (cartOpen)
|
||||||
{
|
{
|
||||||
SNES9X_SaveSRAM();
|
SNES9X_SaveSRAM();
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,18 @@
|
||||||
|
//
|
||||||
|
// snes9x_framework.h
|
||||||
|
// snes9x framework
|
||||||
|
//
|
||||||
|
// Created by Buckley on 7/4/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
//! Project version number for snes9x_framework.
|
||||||
|
FOUNDATION_EXPORT double snes9x_frameworkVersionNumber;
|
||||||
|
|
||||||
|
//! Project version string for snes9x_framework.
|
||||||
|
FOUNDATION_EXPORT const unsigned char snes9x_frameworkVersionString[];
|
||||||
|
|
||||||
|
// In this header, you should import all the public headers of your framework using statements like #import <snes9x_framework/PublicHeader.h>
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue