From 2af9a88744a6ee5e7cdc518cadc7413108d2ed16 Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Thu, 23 May 2019 18:18:53 -0700 Subject: [PATCH] Remove outdated pascal specifier --- macosx/mac-appleevent.cpp | 20 +-- macosx/mac-audio.mm | 8 +- macosx/mac-cart.mm | 49 +++---- macosx/mac-cheat.cpp | 16 +-- macosx/mac-cheatfinder.cpp | 16 +-- macosx/mac-client.cpp | 12 +- macosx/mac-coreimage.mm | 4 +- macosx/mac-dialog.cpp | 18 +-- macosx/mac-dialog.h | 2 +- macosx/mac-joypad.cpp | 8 +- macosx/mac-keyboard.cpp | 12 +- macosx/mac-multicart.cpp | 8 +- macosx/mac-os.mm | 20 +-- macosx/mac-prefs.cpp | 24 ++-- macosx/mac-screenshot.cpp | 267 +++++++++++++++---------------------- macosx/mac-screenshot.h | 6 +- macosx/mac-server.cpp | 8 +- macosx/mac-snes9x.cpp | 36 ++--- 18 files changed, 231 insertions(+), 303 deletions(-) diff --git a/macosx/mac-appleevent.cpp b/macosx/mac-appleevent.cpp index 2b2366bd..03c7db48 100755 --- a/macosx/mac-appleevent.cpp +++ b/macosx/mac-appleevent.cpp @@ -27,14 +27,14 @@ static AEEventHandlerUPP oappUPP, rappUPP, pdocUPP, quitUPP, odocUPP; -static pascal OSErr AEoapp (const AppleEvent *, AppleEvent *, long); -static pascal OSErr AErapp (const AppleEvent *, AppleEvent *, long); -static pascal OSErr AEpdoc (const AppleEvent *, AppleEvent *, long); -static pascal OSErr AEquit (const AppleEvent *, AppleEvent *, long); -static pascal OSErr AEodoc (const AppleEvent *, AppleEvent *, long); +static OSErr AEoapp (const AppleEvent *, AppleEvent *, long); +static OSErr AErapp (const AppleEvent *, AppleEvent *, long); +static OSErr AEpdoc (const AppleEvent *, AppleEvent *, long); +static OSErr AEquit (const AppleEvent *, AppleEvent *, long); +static OSErr AEodoc (const AppleEvent *, AppleEvent *, long); -static pascal OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) +static OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { if (running) return (noErr); @@ -53,7 +53,7 @@ static pascal OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, lo return (noErr); } -static pascal OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) +static OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { if (running) return (noErr); @@ -80,12 +80,12 @@ static pascal OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, lo return (noErr); } -static pascal OSErr AEpdoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) +static OSErr AEpdoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { return (errAEEventNotHandled); } -static pascal OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) +static OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { if (running) return (noErr); @@ -96,7 +96,7 @@ static pascal OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, lo return (noErr); } -static pascal OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) +static OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { OSErr err; FSRef ref; diff --git a/macosx/mac-audio.mm b/macosx/mac-audio.mm index 3fe2b425..4b951062 100644 --- a/macosx/mac-audio.mm +++ b/macosx/mac-audio.mm @@ -67,8 +67,8 @@ static void ReplaceAudioUnitCarbonView (void); static void ResizeSoundEffectsDialog (HIViewRef); static void MacSamplesAvailableCallBack (void *); static OSStatus MacAURenderCallBack (void *, AudioUnitRenderActionFlags *, const AudioTimeStamp *, UInt32, UInt32, AudioBufferList *); -static pascal OSStatus SoundEffectsEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus SoundEffectsEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef, EventRef, void *); void InitMacSound (void) @@ -830,7 +830,7 @@ void ConfigureSoundEffects (void) } } -static pascal OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl; @@ -863,7 +863,7 @@ static pascal OSStatus SoundEffectsCarbonViewEventHandler (EventHandlerCallRef i return (result); } -static pascal OSStatus SoundEffectsEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus SoundEffectsEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; diff --git a/macosx/mac-cart.mm b/macosx/mac-cart.mm index d23d34a4..5f06f2db 100755 --- a/macosx/mac-cart.mm +++ b/macosx/mac-cart.mm @@ -15,6 +15,7 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 Michael Donald Buckley ***********************************************************************************/ @@ -60,21 +61,21 @@ static NavState gSheetNav; static NSAutoreleasePool *gPool; static NSPopUpButton *gPopM, *gPopI, *gPopV, *gPopH; -static pascal void NavGenericOpenEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); -static pascal void NavGenericSaveEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); -static pascal Boolean NavOpenCartFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); -static pascal Boolean NavDefrostFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); -static pascal Boolean NavPlayMovieFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); +static void NavGenericOpenEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static void NavGenericSaveEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static Boolean NavOpenCartFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); +static Boolean NavDefrostFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); +static Boolean NavPlayMovieFromFilter (AEDesc *, void *, NavCallBackUserData, NavFilterModes); #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT static void GlobalPointToWindowLocalPoint (Point *, WindowRef); -static pascal void NavOpenCartEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); -static pascal void NavRecordMovieToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); -static pascal void NavPlayMovieFromEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); -static pascal void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static void NavOpenCartEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static void NavRecordMovieToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static void NavPlayMovieFromEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); +static void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage, NavCBRecPtr, NavCallBackUserData); #endif #ifdef MAC_TIGER_PANTHER_SUPPORT -static pascal Boolean NavDefrostFromPreview (NavCBRecPtr, NavCallBackUserData); -static pascal Boolean NavPlayMovieFromPreview (NavCBRecPtr, NavCallBackUserData); +static Boolean NavDefrostFromPreview (NavCBRecPtr, NavCallBackUserData); +static Boolean NavPlayMovieFromPreview (NavCBRecPtr, NavCallBackUserData); #endif @@ -1085,7 +1086,7 @@ bool8 NavEndChooseFolderSheet (FSRef *ref) return (false); } -static pascal void NavGenericOpenEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavGenericOpenEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { OSStatus err; NavReplyRecord reply; @@ -1163,7 +1164,7 @@ static pascal void NavGenericOpenEventHandler (const NavEventCallbackMessage cal } } -static pascal void NavGenericSaveEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavGenericSaveEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { OSStatus err; NavReplyRecord reply; @@ -1221,7 +1222,7 @@ static pascal void NavGenericSaveEventHandler (const NavEventCallbackMessage cal } #ifdef MAC_LEOPARD_TIGER_PANTHER_SUPPORT -static pascal void NavOpenCartEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavOpenCartEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { static Boolean embedded = false; @@ -1385,7 +1386,7 @@ static pascal void NavOpenCartEventHandler (const NavEventCallbackMessage callBa } } -static pascal void NavPlayMovieFromEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavPlayMovieFromEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { static Boolean embedded = false; @@ -1509,7 +1510,7 @@ static pascal void NavPlayMovieFromEventHandler (const NavEventCallbackMessage c } } -static pascal void NavRecordMovieToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavRecordMovieToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { static Boolean embedded = false; @@ -1667,7 +1668,7 @@ static pascal void NavRecordMovieToEventHandler (const NavEventCallbackMessage c } } -static pascal void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { static Boolean embedded = false; @@ -1804,7 +1805,7 @@ static pascal void NavQTMovieRecordToEventHandler (const NavEventCallbackMessage } #endif -static pascal Boolean NavOpenCartFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) +static Boolean NavOpenCartFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) { OSStatus err; AEDesc resultDesc; @@ -1849,7 +1850,7 @@ static pascal Boolean NavOpenCartFilter (AEDesc *theItem, void *ninfo, NavCallBa return (result); } -static pascal Boolean NavDefrostFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) +static Boolean NavDefrostFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) { OSStatus err; AEDesc resultDesc; @@ -1890,7 +1891,7 @@ static pascal Boolean NavDefrostFromFilter (AEDesc *theItem, void *ninfo, NavCal return (result); } -static pascal Boolean NavPlayMovieFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) +static Boolean NavPlayMovieFromFilter (AEDesc *theItem, void *ninfo, NavCallBackUserData callbackUD, NavFilterModes filterMode) { OSStatus err; AEDesc resultDesc; @@ -1932,7 +1933,7 @@ static pascal Boolean NavPlayMovieFromFilter (AEDesc *theItem, void *ninfo, NavC } #ifdef MAC_TIGER_PANTHER_SUPPORT -static pascal Boolean NavDefrostFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static Boolean NavDefrostFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { if (systemVersion >= 0x1050) return (true); @@ -2006,7 +2007,7 @@ static pascal Boolean NavDefrostFromPreview (NavCBRecPtr callBackParms, NavCallB bounds.size.width = 128.0f; bounds.size.height = 120.0f; - DrawThumbnailResource(&ref, ctx, bounds); + DrawThumbnailFromExtendedAttribute(&ref, ctx, bounds); HIThemeTextInfo textinfo; @@ -2045,7 +2046,7 @@ static pascal Boolean NavDefrostFromPreview (NavCBRecPtr callBackParms, NavCallB return (result); } -static pascal Boolean NavPlayMovieFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) +static Boolean NavPlayMovieFromPreview (NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { if (systemVersion >= 0x1050) return (true); @@ -2178,7 +2179,7 @@ static pascal Boolean NavPlayMovieFromPreview (NavCBRecPtr callBackParms, NavCal bounds.size.width = 128.0f; bounds.size.height = 120.0f; - DrawThumbnailResource(&ref, ctx, bounds); + DrawThumbnailFromExtendedAttribute(&ref, ctx, bounds); // Text diff --git a/macosx/mac-cheat.cpp b/macosx/mac-cheat.cpp index 27da88cc..ec27feab 100755 --- a/macosx/mac-cheat.cpp +++ b/macosx/mac-cheat.cpp @@ -62,10 +62,10 @@ static void DetachCheatItems (void); static void AddCheatItem (void); static void DeleteCheatItem (void); static void EnableAllCheatItems (void); -static pascal void DBItemNotificationCallBack (HIViewRef, DataBrowserItemID, DataBrowserItemNotification); -static pascal Boolean DBCompareCallBack (HIViewRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID); -static pascal OSStatus DBClientDataCallback (HIViewRef, DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean); -static pascal OSStatus CheatEventHandler (EventHandlerCallRef, EventRef, 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) @@ -341,7 +341,7 @@ static void EnableAllCheatItems (void) err = UpdateDataBrowserItems(dbRef, kDataBrowserNoItem, kDataBrowserNoItem, NULL, kDataBrowserItemNoProperty, kCmCheckBox); } -static pascal OSStatus DBClientDataCallback (HIViewRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue) +static OSStatus DBClientDataCallback (HIViewRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue) { OSStatus err, result; CFStringRef str; @@ -486,7 +486,7 @@ static pascal OSStatus DBClientDataCallback (HIViewRef browser, DataBrowserItemI return (result); } -static pascal Boolean DBCompareCallBack (HIViewRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty) +static Boolean DBCompareCallBack (HIViewRef browser, DataBrowserItemID itemOne, DataBrowserItemID itemTwo, DataBrowserPropertyID sortProperty) { Boolean result = false; @@ -511,7 +511,7 @@ static pascal Boolean DBCompareCallBack (HIViewRef browser, DataBrowserItemID it return (result); } -static pascal void DBItemNotificationCallBack (HIViewRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message) +static void DBItemNotificationCallBack (HIViewRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message) { OSStatus err; HIViewRef ctl; @@ -531,7 +531,7 @@ static pascal void DBItemNotificationCallBack (HIViewRef browser, DataBrowserIte } } -static pascal OSStatus CheatEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus CheatEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef; diff --git a/macosx/mac-cheatfinder.cpp b/macosx/mac-cheatfinder.cpp index 34547fa0..c7eef1b2 100755 --- a/macosx/mac-cheatfinder.cpp +++ b/macosx/mac-cheatfinder.cpp @@ -156,10 +156,10 @@ static SInt64 CheatFinderReadBytes (UInt8 *, UInt32); static SInt64 CheatFinderGetValueEditText (ControlRef); static Boolean CheatFinderCompare (SInt64, SInt64); static HIViewPartCode CheatFinderListViewFindPart (EventRef, ListViewData *, SInt32 *); -static pascal OSStatus CheatFinderListViewHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus CheatFinderSheetEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus CheatFinderWindowEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus CheatFinderListViewHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus CheatFinderSheetEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus CheatFinderWindowEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef, EventRef, void *); void InitCheatFinder (void) @@ -505,7 +505,7 @@ static SInt64 CheatFinderReadBytes (UInt8 *mem, UInt32 addr) return (0); } -static pascal OSStatus CheatFinderWindowEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus CheatFinderWindowEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowData *cf; @@ -1176,7 +1176,7 @@ static void CheatFinderEndAddEntrySheet (WindowData *cf) } } -static pascal OSStatus CheatFinderSheetEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus CheatFinderSheetEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowData *cf = (WindowData *) inUserData; @@ -1285,7 +1285,7 @@ static void CheatFinderAddEntry (SInt64 value, char *description) } } -static pascal OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData) +static OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData) { OSStatus err, result = eventNotHandledErr; HIViewRef view = (HIViewRef) userData; @@ -1736,7 +1736,7 @@ static void CheatFinderListViewScrollToThere (float where, ListViewData *myData) } } -static pascal OSStatus CheatFinderListViewHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus CheatFinderListViewHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; ListViewData *myData = (ListViewData *) inUserData; diff --git a/macosx/mac-client.cpp b/macosx/mac-client.cpp index e7f0d217..2b905fb0 100644 --- a/macosx/mac-client.cpp +++ b/macosx/mac-client.cpp @@ -136,9 +136,9 @@ static bool8 NPClientReplyPhaseSpanTest (void); static void * NPClientConnectThread (void *); static void * NPClientPrepareThread (void *); static void * NPClientNetPlayThread (void *); -static pascal void NPClientDialogTimerHandler (EventLoopTimerRef, void *); -static pascal OSStatus NPClientDialogEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus NPClientSheetEventHandler (EventHandlerCallRef, EventRef, void *); +static void NPClientDialogTimerHandler (EventLoopTimerRef, void *); +static OSStatus NPClientDialogEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus NPClientSheetEventHandler (EventHandlerCallRef, EventRef, void *); bool8 NPClientDialog (void) @@ -230,7 +230,7 @@ bool8 NPClientDialog (void) return (!npclient.dialogcancel); } -static pascal OSStatus NPClientDialogEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus NPClientDialogEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; @@ -335,7 +335,7 @@ static pascal OSStatus NPClientDialogEventHandler (EventHandlerCallRef inHandler return (result); } -static pascal void NPClientDialogTimerHandler (EventLoopTimerRef inTimer, void *userData) +static void NPClientDialogTimerHandler (EventLoopTimerRef inTimer, void *userData) { WindowRef window = (WindowRef) userData; HIViewRef ctl; @@ -1017,7 +1017,7 @@ static void NPClientEndPlayerListSheet (void) err = HideSheetWindow(sRef); } -static pascal OSStatus NPClientSheetEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus NPClientSheetEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { if (!npclient.dialogsheet) return (eventNotHandledErr); diff --git a/macosx/mac-coreimage.mm b/macosx/mac-coreimage.mm index 48f479a6..7c32b7e4 100644 --- a/macosx/mac-coreimage.mm +++ b/macosx/mac-coreimage.mm @@ -93,7 +93,7 @@ static void ReplaceFilterUI (WindowRef); static void FilterUIAddSubviews (WindowRef, HIViewRef); static void FilterUISetValues (HIViewRef); static bool8 IsCoreImageFilterSupported (CIFilter *); -static pascal OSStatus CoreImageFilterEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef, EventRef, void *); void InitCoreImage (void) @@ -667,7 +667,7 @@ static void FilterUISetValues (HIViewRef parent) } } -static pascal OSStatus CoreImageFilterEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus CoreImageFilterEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef window = (WindowRef) inUserData; diff --git a/macosx/mac-dialog.cpp b/macosx/mac-dialog.cpp index 71bf8dc6..9082ae0b 100755 --- a/macosx/mac-dialog.cpp +++ b/macosx/mac-dialog.cpp @@ -44,10 +44,10 @@ static void AutofireWriteAllSettings (int, HIViewRef); static void AutofireWriteSetting (int, uint16 *, HIViewRef); static void AutofireSelectTabPane (HIViewRef, SInt16); static OSStatus UpdateTextControlView (HIViewRef); -static pascal void AutofireSliderActionProc (HIViewRef, HIViewPartCode); -static pascal OSStatus RomInfoEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus AutofireTabEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus AutofireWindowEventHandler (EventHandlerCallRef, EventRef, void *); +static void AutofireSliderActionProc (HIViewRef, HIViewPartCode); +static OSStatus RomInfoEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus AutofireTabEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus AutofireWindowEventHandler (EventHandlerCallRef, EventRef, void *); #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 extern "C" FMFont FMGetFontFromATSFontRef (ATSFontRef iFont); @@ -333,7 +333,7 @@ void AboutDialog (void) } } -pascal OSStatus DefaultEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +OSStatus DefaultEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; @@ -787,7 +787,7 @@ static void AutofireSelectTabPane (HIViewRef tabControl, SInt16 index) HIViewSetNeedsDisplay(tabControl, true); } -static pascal OSStatus AutofireTabEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus AutofireTabEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl; @@ -810,7 +810,7 @@ static pascal OSStatus AutofireTabEventHandler (EventHandlerCallRef inHandlerRef return (result); } -static pascal OSStatus AutofireWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus AutofireWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; @@ -880,7 +880,7 @@ static pascal OSStatus AutofireWindowEventHandler (EventHandlerCallRef inHandler return (result); } -static pascal void AutofireSliderActionProc (HIViewRef slider, HIViewPartCode partCode) +static void AutofireSliderActionProc (HIViewRef slider, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid; @@ -1081,7 +1081,7 @@ static void RomInfoBuildInfoText (char *romtext) sprintf(romtext, "%s%s", s1, s2); } -static pascal OSStatus RomInfoEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus RomInfoEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; diff --git a/macosx/mac-dialog.h b/macosx/mac-dialog.h index b2b1b900..89d7b776 100755 --- a/macosx/mac-dialog.h +++ b/macosx/mac-dialog.h @@ -55,6 +55,6 @@ OSStatus SetEditTextCStr (HIViewRef, char *, Boolean); OSStatus CopyEditTextCFString (HIViewRef, CFStringRef *); OSStatus SetEditTextCFString (HIViewRef, CFStringRef, Boolean); OSStatus SetEditTextSelection (HIViewRef, SInt16, SInt16); -pascal OSStatus DefaultEventHandler (EventHandlerCallRef, EventRef, void *); +OSStatus DefaultEventHandler (EventHandlerCallRef, EventRef, void *); #endif diff --git a/macosx/mac-joypad.cpp b/macosx/mac-joypad.cpp index 8b1b664d..556f2703 100755 --- a/macosx/mac-joypad.cpp +++ b/macosx/mac-joypad.cpp @@ -477,8 +477,8 @@ static int gIconNumber[kNeedCount] = }; static void JoypadSetDirectionInfo (void); -static pascal void IdleTimer (EventLoopTimerRef, void *); -static pascal OSStatus ControllerEventHandler (EventHandlerCallRef, EventRef, void *); +static void IdleTimer (EventLoopTimerRef, void *); +static OSStatus ControllerEventHandler (EventHandlerCallRef, EventRef, void *); void SaveControllerSettings (void) @@ -591,7 +591,7 @@ void LoadControllerSettings (void) JoypadSetDirectionInfo(); } -static pascal OSStatus ControllerEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus ControllerEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef; @@ -779,7 +779,7 @@ static pascal OSStatus ControllerEventHandler (EventHandlerCallRef inHandlerCall return (result); } -static pascal void IdleTimer (EventLoopTimerRef inTimer, void *userData) +static void IdleTimer (EventLoopTimerRef inTimer, void *userData) { static uint32 old[MAC_MAX_PLAYERS] = { ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 }; diff --git a/macosx/mac-keyboard.cpp b/macosx/mac-keyboard.cpp index 8e77767b..4e348ef7 100755 --- a/macosx/mac-keyboard.cpp +++ b/macosx/mac-keyboard.cpp @@ -299,9 +299,9 @@ static void DrawPlacedIcon (CGContextRef, int); static void DrawDraggedIcon (CGContextRef, int, CGPoint *); static Boolean KeyCodeInUse (int); static int FindHitKey (HIPoint, CGRect *, CGPoint *); -static pascal OSStatus KeyWindowEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus KeyLegendEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus KeyLayoutEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus KeyWindowEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus KeyLegendEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus KeyLayoutEventHandler (EventHandlerCallRef, EventRef, void *); #define kCustomLayoutViewClassID CFSTR("com.snes9x.macos.snes9x.keylayout") @@ -780,7 +780,7 @@ static int FindHitKey (HIPoint where, CGRect *keybounds, CGPoint *offset) return (hit); } -static pascal OSStatus KeyWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus KeyWindowEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; @@ -830,7 +830,7 @@ static pascal OSStatus KeyWindowEventHandler (EventHandlerCallRef inHandlerRef, return (result); } -static pascal OSStatus KeyLegendEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus KeyLegendEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef view = (HIViewRef) inUserData; @@ -863,7 +863,7 @@ static pascal OSStatus KeyLegendEventHandler (EventHandlerCallRef inHandlerRef, return (result); } -static pascal OSStatus KeyLayoutEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus KeyLayoutEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; CustomViewData *data = (CustomViewData *) inUserData; diff --git a/macosx/mac-multicart.cpp b/macosx/mac-multicart.cpp index 0f075145..c6065084 100644 --- a/macosx/mac-multicart.cpp +++ b/macosx/mac-multicart.cpp @@ -30,8 +30,8 @@ #define truncEnd 0 #endif -static pascal OSStatus MultiCartEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus MultiCartPaneEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus MultiCartEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef, EventRef, void *); static int multiCartDragHilite; static Boolean multiCartDialogResult; @@ -172,7 +172,7 @@ Boolean MultiCartDialog (void) return (multiCartDialogResult); } -static pascal OSStatus MultiCartEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus MultiCartEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef window = (WindowRef) inUserData; @@ -324,7 +324,7 @@ static pascal OSStatus MultiCartEventHandler (EventHandlerCallRef inHandlerRef, return (result); } -static pascal OSStatus MultiCartPaneEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus MultiCartPaneEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef view; diff --git a/macosx/mac-os.mm b/macosx/mac-os.mm index 3ea95f0b..9479b2c5 100644 --- a/macosx/mac-os.mm +++ b/macosx/mac-os.mm @@ -15,6 +15,7 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 Michael Donald Buckley ***********************************************************************************/ @@ -34,7 +35,6 @@ #endif #import -#import #import #import "mac-prefix.h" @@ -352,10 +352,10 @@ static void UpdateFreezeDefrostScreen (int, CGImageRef, uint8 *, CGContextRef); static void * MacSnes9xThread (void *); static OSStatus HandleMenuChoice (UInt32, Boolean *); static inline void EmulationLoop (void); -static pascal OSStatus MainEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus SubEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus GameWindowEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus GameWindowUserPaneEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus MainEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus SubEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus GameWindowEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus GameWindowUserPaneEventHandler (EventHandlerCallRef, EventRef, void *); int main (int argc, char **argv) @@ -600,7 +600,7 @@ static inline void EmulationLoop (void) S9xMovieShutdown(); } -static pascal OSStatus MainEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus MainEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; Boolean done = false; @@ -653,7 +653,7 @@ static pascal OSStatus MainEventHandler (EventHandlerCallRef inHandlerCallRef, E return (result); } -static pascal OSStatus SubEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus SubEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; @@ -939,7 +939,7 @@ void DeinitGameWindow (void) gWindow = NULL; } -static pascal OSStatus GameWindowEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus GameWindowEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIRect rct; @@ -1052,7 +1052,7 @@ static pascal OSStatus GameWindowEventHandler (EventHandlerCallRef inHandlerCall return (result); } -static pascal OSStatus GameWindowUserPaneEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) +static OSStatus GameWindowUserPaneEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; @@ -2091,7 +2091,7 @@ int PromptFreezeDefrost (Boolean freezing) newestDate = currentDate; } - DrawThumbnailResource(&ref, ctx, rct); + DrawThumbnailFromExtendedAttribute(filename, ctx, rct); CGContextSetShouldAntialias(ctx, false); CGContextSetLineWidth(ctx, 1.0f); diff --git a/macosx/mac-prefs.cpp b/macosx/mac-prefs.cpp index f72b43ca..a8577102 100755 --- a/macosx/mac-prefs.cpp +++ b/macosx/mac-prefs.cpp @@ -206,12 +206,12 @@ static PrefList prefList[] = #define kPrefListSize (sizeof(prefList) / sizeof(prefList[0])) static void SelectTabPane (HIViewRef, SInt16); -static pascal void InputRateSliderActionProc (HIViewRef, HIViewPartCode); -static pascal void LittleArrowsActionProc (HIViewRef, HIViewPartCode); -static pascal OSStatus InputRateTextEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus AspectRatioTextEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus TabEventHandler (EventHandlerCallRef, EventRef, void *); -static pascal OSStatus PreferencesEventHandler (EventHandlerCallRef, EventRef, void *); +static void InputRateSliderActionProc (HIViewRef, HIViewPartCode); +static void LittleArrowsActionProc (HIViewRef, HIViewPartCode); +static OSStatus InputRateTextEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus AspectRatioTextEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus TabEventHandler (EventHandlerCallRef, EventRef, void *); +static OSStatus PreferencesEventHandler (EventHandlerCallRef, EventRef, void *); void SavePrefs (void) @@ -1170,7 +1170,7 @@ static void SelectTabPane (HIViewRef tabControl, SInt16 index) HIViewSetNeedsDisplay(tabControl, true); } -static pascal void InputRateSliderActionProc (HIViewRef slider, HIViewPartCode partCode) +static void InputRateSliderActionProc (HIViewRef slider, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid; @@ -1184,7 +1184,7 @@ static pascal void InputRateSliderActionProc (HIViewRef slider, HIViewPartCode p SetStaticTextCStr(ctl, num, true); } -static pascal void LittleArrowsActionProc (HIViewRef arrows, HIViewPartCode partCode) +static void LittleArrowsActionProc (HIViewRef arrows, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid = { 'msc2', iNibMTurboSkipText }; @@ -1201,7 +1201,7 @@ static pascal void LittleArrowsActionProc (HIViewRef arrows, HIViewPartCode part SetStaticTextCStr(ctl, num, true); } -static pascal OSStatus InputRateTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus InputRateTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl, slider; @@ -1234,7 +1234,7 @@ static pascal OSStatus InputRateTextEventHandler (EventHandlerCallRef inHandlerR return (result); } -static pascal OSStatus AspectRatioTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus AspectRatioTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl, slider; @@ -1264,7 +1264,7 @@ static pascal OSStatus AspectRatioTextEventHandler (EventHandlerCallRef inHandle return (result); } -static pascal OSStatus TabEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus TabEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl; @@ -1287,7 +1287,7 @@ static pascal OSStatus TabEventHandler (EventHandlerCallRef inHandlerRef, EventR return (result); } -static pascal OSStatus PreferencesEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus PreferencesEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; diff --git a/macosx/mac-screenshot.cpp b/macosx/mac-screenshot.cpp index 913f373b..452f8647 100644 --- a/macosx/mac-screenshot.cpp +++ b/macosx/mac-screenshot.cpp @@ -15,15 +15,15 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 Michael Donald Buckley ***********************************************************************************/ +#include #include "snes9x.h" #include "memmap.h" #include "screenshot.h" -#include - #include "mac-prefix.h" #include "mac-file.h" #include "mac-gworld.h" @@ -31,92 +31,50 @@ #include "mac-render.h" #include "mac-screenshot.h" -static Handle GetScreenAsRawHandle (int, int); -static void ExportCGImageToPNGFile (CGImageRef, const char *); +const char *extendedAttributeName = "com.snes9x.preview"; -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 -typedef struct QDPict* QDPictRef; -extern "C" QDPictRef QDPictCreateWithProvider (CGDataProviderRef provider); -extern "C" void QDPictRelease (QDPictRef pictRef); -extern "C" OSStatus QDPictDrawToCGContext (CGContextRef ctx, CGRect rect, QDPictRef pictRef); -#endif +unsigned char *CGImageToPNGData (CGImageRef image, CFIndex *outLength); -static Handle GetScreenAsRawHandle (int destWidth, int destHeight) +unsigned char *CGImageToPNGData (CGImageRef image, CFIndex *outLength) { - CGContextRef ctx; - CGColorSpaceRef color; - CGImageRef image; - Handle data = NULL; + if (!outLength) + { + return NULL; + } - image = CreateGameScreenCGImage(); - if (image) - { - data = NewHandleClear(destWidth * destHeight * 2); - if (data) - { - HLock(data); + CFMutableDataRef dataRef = CFDataCreateMutable(kCFAllocatorDefault, 0); + if (dataRef) + { + CGImageDestinationRef dest = CGImageDestinationCreateWithData(dataRef, kUTTypePNG, 1, NULL); - color = CGColorSpaceCreateDeviceRGB(); - if (color) - { - ctx = CGBitmapContextCreate(*data, destWidth, destHeight, 5, destWidth * 2, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrder16Big : 0)); - if (ctx) - { - CGContextDrawImage(ctx, CGRectMake(0.0f, 0.0f, (float) destWidth, (float) destHeight), image); - CGContextRelease(ctx); - } + if (dest) + { + CGImageDestinationAddImage(dest, image, NULL); + CGImageDestinationFinalize(dest); + CFRelease(dest); - CGColorSpaceRelease(color); - } + *outLength = CFDataGetLength(dataRef); + unsigned char *data = (unsigned char *)malloc(*outLength); - HUnlock(data); - } + if (data) + { + CFDataGetBytes(dataRef, CFRangeMake(0, *outLength), data); + return data; + } + } + else + { + CFRelease(dataRef); + } + } - CGImageRelease(image); - } - - return (data); -} - -void WriteThumbnailToResourceFork (FSRef *ref, int destWidth, int destHeight) -{ - OSStatus err; - HFSUniStr255 fork; - SInt16 resf; - - err = FSGetResourceForkName(&fork); - if (err == noErr) - { - err = FSCreateResourceFork(ref, fork.length, fork.unicode, 0); - if ((err == noErr) || (err == errFSForkExists)) - { - err = FSOpenResourceFile(ref, fork.length, fork.unicode, fsWrPerm, &resf); - if (err == noErr) - { - Handle pict; - - pict = GetScreenAsRawHandle(destWidth, destHeight); - if (pict) - { - AddResource(pict, 'Thum', 128, "\p"); - WriteResource(pict); - ReleaseResource(pict); - } - - CloseResFile(resf); - } - } - } + return NULL; } static void ExportCGImageToPNGFile (CGImageRef image, const char *path) { - OSStatus err; - GraphicsExportComponent exporter; - CFStringRef str; - CFURLRef url; - Handle dataRef; - OSType dataRefType; + CFStringRef str; + CFURLRef url; str = CFStringCreateWithCString(kCFAllocatorDefault, path, kCFStringEncodingUTF8); if (str) @@ -124,25 +82,19 @@ static void ExportCGImageToPNGFile (CGImageRef image, const char *path) url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, str, kCFURLPOSIXPathStyle, false); if (url) { - err = QTNewDataReferenceFromCFURL(url, 0, &dataRef, &dataRefType); - if (err == noErr) - { - err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePNG, &exporter); - if (err == noErr) - { - err = GraphicsExportSetInputCGImage(exporter, image); - if (err == noErr) - { - err = GraphicsExportSetOutputDataReference(exporter, dataRef, dataRefType); - if (err == noErr) - err = GraphicsExportDoExport(exporter, NULL); - } + CFIndex length = 0; + unsigned char *data = CGImageToPNGData(image, &length); + if (data) + { + FILE *f = fopen(path, "wb"); + if (f) + { + fwrite(data, length, 1, f); + fclose(f); + } - CloseComponent(exporter); - } - - DisposeHandle(dataRef); - } + free(data); + } CFRelease(url); } @@ -198,88 +150,77 @@ CGImageRef CreateBlitScreenCGImage (int width, int height, int rowbytes, uint8 * return (image); } -void DrawThumbnailResource (FSRef *ref, CGContextRef ctx, CGRect bounds) +void WriteThumbnailToExtendedAttribute (const char *path, int destWidth, int destHeight) { - OSStatus err; - CGDataProviderRef prov; - CGColorSpaceRef color; - CGImageRef image; - QDPictRef qdpr; - Handle pict; - HFSUniStr255 fork; - SInt16 resf; - Size size; + CGContextRef ctx; + CGColorSpaceRef color = NULL; + char *data[destWidth * destHeight * 2]; + CGImageRef image = CreateGameScreenCGImage(); - CGContextSaveGState(ctx); + if (image) + { + color = CGColorSpaceCreateDeviceRGB(); + if (color) + { + ctx = CGBitmapContextCreate(data, destWidth, destHeight, 5, destWidth * 2, color, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder16Big); - CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 1.0f); - CGContextFillRect(ctx, bounds); + if (ctx) + { + CGContextDrawImage(ctx, CGRectMake(0.0f, 0.0f, (float) destWidth, (float) destHeight), image); + CGContextRelease(ctx); - err = FSGetResourceForkName(&fork); - if (err == noErr) - { - err = FSOpenResourceFile(ref, fork.length, fork.unicode, fsRdPerm, &resf); - if (err == noErr) - { - pict = Get1Resource('PICT', 128); - if (pict) - { - HLock(pict); + CFIndex length = 0; + unsigned char *data = CGImageToPNGData(image, &length); + if (data) + { + setxattr(path, extendedAttributeName, data, length, 0, 0); + free(data); + } + } - size = GetHandleSize(pict); - prov = CGDataProviderCreateWithData(NULL, (void *) *pict, size, NULL); - if (prov) - { - qdpr = QDPictCreateWithProvider(prov); - if (qdpr) - { - QDPictDrawToCGContext(ctx, bounds, qdpr); - QDPictRelease(qdpr); - } + CGColorSpaceRelease(color); + } - CGDataProviderRelease(prov); - } + CGImageRelease(image); + } +} - HUnlock(pict); - ReleaseResource(pict); - } - else - { - pict = Get1Resource('Thum', 128); - if (pict) - { - HLock(pict); +void DrawThumbnailFomExtendedAttribute (const char *path, CGContextRef ctx, CGRect bounds) +{ + CGContextSaveGState(ctx); - size = GetHandleSize(pict); - prov = CGDataProviderCreateWithData(NULL, (void *) *pict, size, NULL); - if (prov) - { - color = CGColorSpaceCreateDeviceRGB(); - if (color) - { - image = CGImageCreate(128, 120, 5, 16, 256, color, kCGImageAlphaNoneSkipFirst | ((systemVersion >= 0x1040) ? kCGBitmapByteOrder16Big : 0), prov, NULL, 0, kCGRenderingIntentDefault); - if (image) - { - CGContextDrawImage(ctx, bounds, image); - CGImageRelease(image); - } + CGContextSetRGBFillColor(ctx, 0.0f, 0.0f, 0.0f, 1.0f); + CGContextFillRect(ctx, bounds); - CGColorSpaceRelease(color); - } + ssize_t size = getxattr(path, extendedAttributeName, NULL, 0, 0, 0); - CGDataProviderRelease(prov); - } + if ( size > 0 ) + { + unsigned char *buffer = (unsigned char *)malloc(size); + if (buffer != NULL) + { + CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer, size, NULL); + if (data) + { + CGImageSourceRef source = CGImageSourceCreateWithData(data, NULL); + if (source) + { + CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL); + if (image) + { + CGContextDrawImage(ctx, bounds, image); + CGImageRelease(image); + } + } - HUnlock(pict); - ReleaseResource(pict); - } - } + CFRelease(data); + } - CloseResFile(resf); - } - } + free(buffer); + } + } - CGContextRestoreGState(ctx); + CGContextRestoreGState(ctx); } bool8 S9xDoScreenshot (int width, int height) diff --git a/macosx/mac-screenshot.h b/macosx/mac-screenshot.h index 444f4e1a..7d858f7d 100644 --- a/macosx/mac-screenshot.h +++ b/macosx/mac-screenshot.h @@ -15,15 +15,15 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 Michael Donald Buckley ***********************************************************************************/ #ifndef _mac_scheenshot_h_ #define _mac_scheenshot_h_ -void WriteThumbnailToResourceFork (FSRef *, int, int); -void DrawThumbnailResource (FSRef *, CGContextRef, CGRect); -PicHandle GetScreenAsPicHandle (int, int, int, int); +void WriteThumbnailToExtendedAttribute (const char *path, int destWidth, int destHeight); +void DrawThumbnailFromExtendedAttribute(const char *path, CGContextRef, CGRect); CGImageRef CreateGameScreenCGImage (void); CGImageRef CreateBlitScreenCGImage (int, int, int, uint8 *); diff --git a/macosx/mac-server.cpp b/macosx/mac-server.cpp index f2145743..69028fd8 100644 --- a/macosx/mac-server.cpp +++ b/macosx/mac-server.cpp @@ -129,8 +129,8 @@ static bool8 NPServerSendPlayerListToClient (int); static void * NPServerListenLoop (void *); static void * NPServerProcessThread (void *); static void * NPServerNetPlayThread (void *); -static pascal void NPServerDialogTimerHandler (EventLoopTimerRef, void *); -static pascal OSStatus NPServerDialogEventHandler (EventHandlerCallRef, EventRef, void *); +static void NPServerDialogTimerHandler (EventLoopTimerRef, void *); +static OSStatus NPServerDialogEventHandler (EventHandlerCallRef, EventRef, void *); bool8 NPServerDialog (void) @@ -189,7 +189,7 @@ bool8 NPServerDialog (void) return (!npserver.dialogcancel); } -static pascal void NPServerDialogTimerHandler (EventLoopTimerRef inTimer, void *userData) +static void NPServerDialogTimerHandler (EventLoopTimerRef inTimer, void *userData) { WindowRef window = (WindowRef) userData; CFStringRef ref; @@ -308,7 +308,7 @@ static pascal void NPServerDialogTimerHandler (EventLoopTimerRef inTimer, void * } } -static pascal OSStatus NPServerDialogEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) +static OSStatus NPServerDialogEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; diff --git a/macosx/mac-snes9x.cpp b/macosx/mac-snes9x.cpp index 151f785d..f2e7d050 100755 --- a/macosx/mac-snes9x.cpp +++ b/macosx/mac-snes9x.cpp @@ -15,6 +15,7 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 Michael Donald Buckley ***********************************************************************************/ @@ -238,8 +239,6 @@ void SNES9X_SoftReset (void) bool8 SNES9X_Freeze (void) { - OSStatus err; - FSRef ref; int which; const char *filename; @@ -253,14 +252,11 @@ bool8 SNES9X_Freeze (void) { filename = S9xGetFreezeFilename(which); - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - if (!err) - FSDeleteObject(&ref); + unlink(filename); S9xFreezeGame(filename); ChangeTypeAndCreator(filename, 'SAVE', '~9X~'); - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - WriteThumbnailToResourceFork(&ref, 128, 120); + WriteThumbnailToExtendedAttribute(filename, 128, 120); SNES9X_Go(); @@ -310,22 +306,17 @@ bool8 SNES9X_Defrost (void) bool8 SNES9X_FreezeTo (void) { - OSStatus err; - FSRef ref; - char filename[PATH_MAX + 1]; + char filename[PATH_MAX + 1]; if (cartOpen) { if (NavFreezeTo(filename)) { - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - if (!err) - FSDeleteObject(&ref); + unlink(filename); S9xFreezeGame(filename); - ChangeTypeAndCreator(filename, 'SAVE', '~9X~'); - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - WriteThumbnailToResourceFork(&ref, 128, 120); + ChangeTypeAndCreator(filename, 'SAVE', '~9X~');; + WriteThumbnailToExtendedAttribute(filename, 128, 120); return (true); } @@ -336,7 +327,7 @@ bool8 SNES9X_FreezeTo (void) bool8 SNES9X_DefrostFrom (void) { - char filename[PATH_MAX + 1]; + char filename[PATH_MAX + 1]; if (cartOpen) { @@ -355,17 +346,13 @@ bool8 SNES9X_DefrostFrom (void) bool8 SNES9X_RecordMovie (void) { - OSStatus err; - FSRef ref; - char filename[PATH_MAX + 1]; + char filename[PATH_MAX + 1]; if (cartOpen) { if (NavRecordMovieTo(filename)) { - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - if (!err) - FSDeleteObject(&ref); + unlink(filename); int r; uint8 opt = 0, mask = 0; @@ -386,8 +373,7 @@ bool8 SNES9X_RecordMovie (void) if ((macRecordFlag & (1 << 5)) == 0) { - err = FSPathMakeRef((unsigned char *) filename, &ref, NULL); - WriteThumbnailToResourceFork(&ref, 128, 120); + WriteThumbnailToExtendedAttribute(filename, 128, 120); } SNES9X_Go();