ZSNES on Intel Mac, further progress

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

tehnick
Hazed
Posts: 52
Joined: Wed Oct 06, 2004 1:41 am

Post by tehnick »

Yes, I know there is custom res support. But considering those resolutions will most likely be used by majority of Mac users, it would only make sense to include them in the GUI... atleast in the Mac version anyway.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

:roll:
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
polyh3dron
Rookie
Posts: 11
Joined: Mon Jun 19, 2006 10:05 am

Post by polyh3dron »

would someone be so kind as to compile and post the latest working osx zsnes binary? that last one which was posted did not work.

EDIT: Nevermind, I just realized that by "xcode project" hector chu meant to get the zsnes osx binary from his site... wow, this runs SO MUCH quicker than bsnes.. great job guys!
polyh3dron
Rookie
Posts: 11
Joined: Mon Jun 19, 2006 10:05 am

Post by polyh3dron »

I've been playing Super Metroid with this on my 17" MacBook Pro and it's been running great.. One question though, would it be that tough to make zsnes output to a secondary display?
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Hey polyh3dron, great to see it working on your end and that you're having fun. The secondary display option seems to be much requested but I don't have any idea what code would be required - I'm quite new to Mac development and I'm not very familiar with ZSNES' code. It might be possible through SDL. I think that if it was implemented on the Windows/Linux side, that it would be automatically available on the Mac.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Can someone tell me how latest SVN is working?
It should detect OGL now, and I commited most of hector's patches with some bug fixes on top of that which I hope work.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Hi Nach, looked over the commits. I don't think the OpenGL library can be found through AC_CHECK_LIB as the library file lies within the OpenGL.framework. When linking with OpenGL you need the -framework OpenGL flag. This is what I meant when I said that fitting Mac OS X OpenGL support into the configure.in was kind of messy. I think that we should assume that Mac OS X has the OpenGL.framework (as it comes with it), and skip the AC_CHECK_LIB for OpenGL. Then add -D__OPENGL__ to CFLAGS, NFLAGS and PSRFLAGS and add -framework OpenGL to LDFLAGS. Also need to add GL_DRAW="\$(WINDIR)/gl_draw.o" as well.

I forgot to mention that I had tried the combination SDL_DOUBLEBUF | SDL_HWSURFACE with no luck, just a black screen again in fullscreen 640x480, and the filters not working properly in the fullscreen modes that do work. Another thing is that double buffering doesn't seem to be supported on the Mac. I get some screen tearing due to the video not being in vsync.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Okay, I believe I fixed it, let me know.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Commit looks good. I will confirm that it works when I get home.
polyh3dron
Rookie
Posts: 11
Joined: Mon Jun 19, 2006 10:05 am

Post by polyh3dron »

does zsnes not support vsync at all? because I can't seem to find it as an option on the osx version.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

SDL port does not have a vsync option at all... Here's a thread that might be helpful in explaining it...

http://board.zsnes.com/phpBB2/viewtopic ... =sdl+vsync
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Hi polyh3dron, unfortunately for now I don't think double buffering is working so as you've found we're going out of vsync and getting tearing. I will have a look at this later.

Nach, your changes were very good. Just one small thing, currently the test deciding whether to run the OpenGL check is:

Code: Select all

if test x$target != *-*-darwin*; then
Unfortunately the != operator tests for an exact string match, so this will evaluate to true even on Mac. So, since we've already decided we've found OpenGL on darwin, we can change the test to:

Code: Select all

if test x$found_opengl != xyes; then
So, if we're on Darwin the left hand side evaluates to xyes, so the test will be false. If we're not on Darwin, the left hand side is just x, so the test will be true and the OpenGL detection will proceed as expected.

Now, things are almost perfect. One more patch that I would like to see go in is:

Code: Select all

Index: linux/sdllink.c
===================================================================
--- linux/sdllink.c	(revision 3305)
+++ linux/sdllink.c	(working copy)
@@ -22,8 +22,6 @@
 #include "sw_draw.h"
 #include "gl_draw.h"
 
-#include <SDL_thread.h>
-
 #include <sys/time.h>
 #include <time.h>
 #include <dirent.h>
The SDL_thread.h header can be removed because sdllink.c includes gblhdr.h, which includes sdl.h. sdl.h already includes SDL_thread.h. This would be nice to get in as it would reduce my current patchset to just gblhdr.h.
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

A possible fix for getting Vsync working in OpenGL is:

Code: Select all

GLint swapInt = 1;
aglSetInteger(aglContext, AGL_SWAP_INTERVAL, &swapInt);
I will test this when I get home.
Helpful link: http://lists.trolltech.com/qt-interest/ ... 311-0.html
Last edited by hector on Tue Jun 20, 2006 5:02 pm, edited 1 time in total.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Okay great.
Thanks for all your help hector, and you too BRPXQZME, couldn't have done it without you guys.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Hey, it was a pleasure and the result has turned out to be really worthwhile. Just imagining the number of people that will now be having fun with ZSNES on the Mac is reward enough. And thank you Nach for putting up with us :D.
zones
New Member
Posts: 5
Joined: Sat Feb 11, 2006 3:36 am
Location: Japan

Post by zones »

hector wrote:A possible fix for getting Vsync working in OpenGL is:

Code: Select all

GLint swapInt = 1;
aglSetInteger(aglContext, AGL_SWAP_INTERVAL, &swapInt);
I will test this when I get home.
That's ok for AGL framework for Carbon.
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Post by kode54 »

For Windows, at least, you can check the extensions list (glGetString(GL_EXTENSIONS)) for "WGL_EXT_swap_control", then retrieve its function pointer with wglGetProcAddress( "wglSwapIntervalEXT" ). The function pointer should be declared as APIENTRY, with a single int parameter.

There's an equivalent glXGetProcAddress and XGL_EXT_swap_control under Linux, but it seems NVidia implements it while ATI doesn't. Hmm...

There's also a library to simplify handling extensions, but that's probably a little overboard just for one extension.
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

Code: Select all

Index: linux/gl_draw.c
===================================================================
--- linux/gl_draw.c     (revision 3313)
+++ linux/gl_draw.c     (working copy)
@@ -80,6 +80,7 @@
        }
 
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+       SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
 
        glvidbuffer = (unsigned short *) malloc(512 * 512 * sizeof(short));
        gl_clearwin();
Makes Vsync work under Mac OS X. According to http://www.libsdl.org/release/changes.html , this new flag was added only recently. I think that this should also make Vsync work under Linux wherever it doesn't work. Anyway since it's such a small change and won't likely impact anything I think it should be submitted straight away.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

hector wrote:

Code: Select all

Index: linux/gl_draw.c
===================================================================
--- linux/gl_draw.c     (revision 3313)
+++ linux/gl_draw.c     (working copy)
@@ -80,6 +80,7 @@
        }
 
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+       SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
 
        glvidbuffer = (unsigned short *) malloc(512 * 512 * sizeof(short));
        gl_clearwin();
Makes Vsync work under Mac OS X. According to http://www.libsdl.org/release/changes.html , this new flag was added only recently. I think that this should also make Vsync work under Linux wherever it doesn't work. Anyway since it's such a small change and won't likely impact anything I think it should be submitted straight away.
Well, I like the idea, but what about people not using 1.2.10?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
hector
Rookie
Posts: 49
Joined: Fri Jun 09, 2006 12:47 am

Post by hector »

This is a tough question. On the one hand, we should take advantage of features available in newer SDL versions, but at the same time we should avoid breaking people's builds because they haven't upgraded their SDL yet. One course of action would be to force everyone to use 1.2.10, and see what people's complaints are if any. Otherwise it could be a long time before this kind of change will be able to be submitted.
There are only about 8 active Zsnes developers, so I wonder what SDL version they are using. If they are all using the latest SDL anyway, then there really isn't any problem.
If you do decide to submit my change, then remember to change the minimum required SDL version in configure.in to 1.2.10.
tehnick
Hazed
Posts: 52
Joined: Wed Oct 06, 2004 1:41 am

Post by tehnick »

There's no excuse for anyone that builds ZSNES from source to not have the latest SDL. I don't see a problem making that a requirement if development calls for it.
spoon0042
Rookie
Posts: 46
Joined: Mon Jun 12, 2006 9:52 pm

Post by spoon0042 »

Or use an #ifdef.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Thank you peanut gallery.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Please be aware that Gentoo, at least, has 1.2.10 hardmasked because it breaks too many packages.
spoon0042
Rookie
Posts: 46
Joined: Mon Jun 12, 2006 9:52 pm

Post by spoon0042 »

sdl.h including sdl_thread.h seems to be new in 1.2.10 too; removing the #include breaks the build with SDL 1.2.8
Post Reply