Previous Thread
Next Thread
Print Thread
Joined: Feb 2004
Posts: 2,258
Likes: 9
Very Senior Member
OP Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,258
Likes: 9
There's been a bit of talk about external monitor support for MacMAME on this forum, and I've mentioned a few times that I've done it with a source code hack. Here's my source patch to do it.

It's done against 0.97u1 because I'm still using Panther at home, and later versions require Xcode 2.2 to build. However, you should be able to patch newer versions of MacMAME fine as the areas affected haven't changed significantly.

Note that this patch doesn't give a UI for changing the monitor. You need to do it with command-line or property list editor.

Use main monitor (the one with menu bar):

Code:
defaults write org.macmame.macmame monitorNo -int 0
Use first monitor:

Code:
defaults write org.macmame.macmame monitorNo -int 1
Use second monitor:

Code:
defaults write org.macmame.macmame monitorNo -int 2
You get the idea. If the selected monitor isn't present (like trying to use the fifth monitor when you only have three) it will use the main monitor.

Here's the actual source patch (sorry, UBB mangles the tabs, I can e-mail the patch if anyone wants it):

Code:
diff -u -r /Volumes/MacMAME Source/macintosh/Source/MacPrefs.c ./macintosh/Source/MacPrefs.c
--- /Volumes/MacMAME Source/macintosh/Source/MacPrefs.c	Mon May 16 13:05:53 2005
+++ ./macintosh/Source/MacPrefs.c	Tue Mar 28 12:44:57 2006
@@ -263,6 +263,7 @@
 	GetPrefAsBoolean(&gPrefs.antialias, CFSTR("vectorAntiAlias"), true);
 	GetPrefAsBoolean(&gPrefs.translucency, CFSTR("vectorTranslucency"), false);
 	GetPrefAsBoolean(&gPrefs.hideDesktop, CFSTR("hideDesktop"), true);
+	GetPrefAsInt(&gPrefs.monitorNo, CFSTR("monitorNo"), 0);
 	GetPrefAsBoolean(&gPrefs.autoSkip, CFSTR("autoSkip"), true);
 	GetPrefAsShort(&gPrefs.frameSkip, CFSTR("manualFrameSkip"), 0);
 	GetPrefAsShort(&gPrefs.windowScale, CFSTR("windowScale"), 2);
diff -u -r /Volumes/MacMAME Source/macintosh/Source/MacPrefs.h ./macintosh/Source/MacPrefs.h
--- /Volumes/MacMAME Source/macintosh/Source/MacPrefs.h	Mon May  9 10:27:35 2005
+++ ./macintosh/Source/MacPrefs.h	Tue Mar 28 12:43:32 2006
@@ -20,6 +20,7 @@
 	Boolean		interlace;
 	Boolean		errorLog;
 	Boolean		hideDesktop;
+	int			monitorNo;
 	Boolean		autoSkip;				// enable automatic frameskipping?
 	Boolean		qualityAudio;			// Play 22kHz or 44kHz audio
 	Boolean		cheat;
diff -u -r /Volumes/MacMAME Source/macintosh/Source/macvideo.c ./macintosh/Source/macvideo.c
--- /Volumes/MacMAME Source/macintosh/Source/macvideo.c	Tue May 31 12:11:40 2005
+++ ./macintosh/Source/macvideo.c	Tue Mar 28 12:42:47 2006
@@ -1964,7 +1964,31 @@
 static void UpdateDisplayState(struct mame_bitmap *inBitmap)
 {
 	// pick the device to consider
-	gDisplay.device = (sPlugin->desc.device) ? sPlugin->desc.device : GetMainDevice();
+	if (sPlugin->desc.device)
+	{
+		gDisplay.device = sPlugin->desc.device;
+	}
+	else
+	{
+		if (gPrefs.monitorNo <= 0)
+		{
+			gDisplay.device = GetMainDevice();
+		}
+		else
+		{
+			int	i;
+			gDisplay.device = GetDeviceList();
+			for (i = 1; i < gPrefs.monitorNo; i++)
+			{
+				gDisplay.device = GetNextDevice(gDisplay.device);
+				if (gDisplay.device == NULL)
+				{
+					gDisplay.device = GetMainDevice();
+					break;
+				}
+			}
+		}
+	}
 
 	// start with the full screen rect
 	sFullScreenRect = sEffectiveScreenRect = (*gDisplay.device)->gdRect;
Brad, might it be possible to have something like this included in a future version of MacMAME?

Joined: Feb 2004
Posts: 312
A
Senior Member
Offline
Senior Member
A
Joined: Feb 2004
Posts: 312
It is probably better to go fullscreen on whichever display the window is mostly on. That way the user can just drag the window.

Joined: Feb 2004
Posts: 2,258
Likes: 9
Very Senior Member
OP Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,258
Likes: 9
OK arekkusu, as requested. This patch will go full screen on whichever display the main window was on. This is great for the current built-in frontend, but if we go with separate front ends later, they need some way to specify which display to use, too.

Code:
diff -u -r /Volumes/MacMAME Source/macintosh/Source/macfrontend.c ./macintosh/Source/macfrontend.c
--- /Volumes/MacMAME Source/macintosh/Source/macfrontend.c	Fri May  6 04:45:43 2005
+++ ./macintosh/Source/macfrontend.c	Tue Mar 28 18:40:46 2006
@@ -352,6 +352,16 @@
 		// handle OK and Cancel buttons
 		if (itemHit == kMainOKButton)
 		{
+			GDHandle	device;
+			if (	GetWindowGreatestAreaDevice(
+						GetDialogWindow(sMainDialog), kWindowContentRgn,
+						&device, NULL
+					) != noErr
+			)
+			{
+				device = GetMainDevice();
+			}
+			SetPreferredDevice(device);
 			sLastSelectedROMSet = selected->romset;
 			*outSelection = *selected->romset;
 			result = true;
diff -u -r /Volumes/MacMAME Source/macintosh/Source/macvideo.c ./macintosh/Source/macvideo.c
--- /Volumes/MacMAME Source/macintosh/Source/macvideo.c	Tue May 31 12:11:40 2005
+++ ./macintosh/Source/macvideo.c	Tue Mar 28 18:42:07 2006
@@ -96,6 +96,7 @@
 // display parameters
 DisplayParameters			gDisplay;					// current state of the display
 const DisplayParameters *	gDisplayState = &gDisplay;	// for external use
+GDHandle					gPreferredDevice = NULL;	// Preferred display
 
 int							frameskip;					// these two are tweaked by the skanky cheat code
 int							autoframeskip;
@@ -1087,6 +1088,28 @@
 #pragma mark ‚ΔΆ Plug-In Management
 
 //===============================================================================
+//	GetPreferredDevice
+//
+//	Set the preferred display.
+//===============================================================================
+
+void SetPreferredDevice(GDHandle device)
+{
+	gPreferredDevice = device;
+}
+
+//===============================================================================
+//	GetPreferredDevice
+//
+//	Return the device that has been set as the preferred display.
+//===============================================================================
+
+GDHandle GetPreferredDevice(void)
+{
+	return gPreferredDevice;
+}
+
+//===============================================================================
 //	InitializePlugins
 //
 //	Searches for and initializes all the plugins.
@@ -1964,7 +1987,21 @@
 static void UpdateDisplayState(struct mame_bitmap *inBitmap)
 {
 	// pick the device to consider
-	gDisplay.device = (sPlugin->desc.device) ? sPlugin->desc.device : GetMainDevice();
+	if (sPlugin->desc.device)
+	{
+		gDisplay.device = sPlugin->desc.device;
+	}
+	else
+	{
+		//	Should already be set, but need to verify that it's valid
+		GDHandle	device = GetDeviceList();
+		while ((device != NULL) && (device != gPreferredDevice))
+			device = GetNextDevice(device);
+		if (device == NULL)
+			gDisplay.device = GetMainDevice();
+		else
+			gDisplay.device = device;
+	}
 
 	// start with the full screen rect
 	sFullScreenRect = sEffectiveScreenRect = (*gDisplay.device)->gdRect;
diff -u -r /Volumes/MacMAME Source/macintosh/Source/macvideo.h ./macintosh/Source/macvideo.h
--- /Volumes/MacMAME Source/macintosh/Source/macvideo.h	Sun Oct  3 07:39:10 2004
+++ ./macintosh/Source/macvideo.h	Tue Mar 28 18:41:00 2006
@@ -16,6 +16,10 @@
 	FUNCTION PROTOTYPES
 ##########################################################################*/
 
+// preferred display
+void		SetPreferredDevice(GDHandle device);
+GDHandle	GetPreferredDevice(void);
+
 // plugin setup
 void		InitializePlugins(void);
 UInt32		GetIndexedPlugin(UInt32 inIndex, StringPtr outShortName, StringPtr outLongName, Boolean *outEnabled);

Joined: Feb 2004
Posts: 2,258
Likes: 9
Very Senior Member
OP Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,258
Likes: 9
With the second patch, launching MacMAME with a ROM file (to bypass the frontend completely) will result in the game always appearing on the main monitor.

Joined: Sep 2000
Posts: 21
Senior Member
Offline
Senior Member
Joined: Sep 2000
Posts: 21
I imagine this is unrelated, but I wonder if this would help (down the road) with games that use more than one monitor, like PunchOut!
Looks kinda silly pillarboxed on a 16X10 display.

Joined: Apr 2006
Posts: 1
-
Junior Member
Offline
Junior Member
-
Joined: Apr 2006
Posts: 1
Newbie question, but how to apply this patch? Don't know much about compiling but can edit text files =).

This patch would make gaming with second monitor inside a cabin much more enjoyable..

Joined: Feb 2004
Posts: 2,258
Likes: 9
Very Senior Member
OP Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,258
Likes: 9
Download the MacMAME source, open a terminal window on the source folder and do "patch -p0 < path/to/patch/file" then open it in Xcode and hit build. That's how I tested it, anyway. The other option is to ask nicely ask Brad to include something like this in the next release.

Joined: Mar 2006
Posts: 5
D
Junior Member
Offline
Junior Member
D
Joined: Mar 2006
Posts: 5
Hi Vas Crabb

call me stupid but i just can not compile patched version.
It gives an error every time
maybe i just do it wrong.
Would you please upload an patched version for PPc ?
it would be very nice.


Thank you

Joined: Feb 2004
Posts: 2,258
Likes: 9
Very Senior Member
OP Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,258
Likes: 9
What kind of error is it giving you? I might be able to help you with it. Also, which version are you patching? Remember you need to run ranlib on the libraries before building.

Joined: Mar 2006
Posts: 5
D
Junior Member
Offline
Junior Member
D
Joined: Mar 2006
Posts: 5
Sorry for long delay

im patching version 103.u2
if i apply this patch
i get this message

Hunk #1 succeeded at 98 (offset 2 lines).
patch: **** malformed patch at line 34: ?

then i just open MacMame.xcodeproj and hit build and go
(i hope its correct way to compile this project im new to this wink )

i get a lot of warning messages and an error
so i just dont know which message to post.

what do you mean by "remeber to run ranlib"
could you please post a step by step Faq of "patching" smile


Link Copied to Clipboard
Who's Online Now
2 members (judge, box), 43 guests, and 3 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics8,957
Posts117,735
Members4,994
Most Online890
Jan 17th, 2020
Forum Host
These forums are hosted by www.retrogamesformac.com
Forum hosted by www.retrogamesformac.com