What's new

mupen64, glN64, and Rice video have been ported to Darwin (X11/GTK2/SDL on MacOS)

dtm

New member
Ok I deleted my previous post because it's totally obsolete. Let's start over, shall we?

Emulation now works on Darwin (X11/gtk2/SDL)! \o/ It's not *playable* due to lack of input device.

Various people from #fink on irc.freenode.net have worked with me on porting Mupen64, glN64, and Rice video to Darwin (X11/gtk2/SDL). I got em started and they did almost all of the work. ;) Thanks mainly to Feanor, who did 90% of the work because I'm not a programmer (I just play one on irc). I don't think it'll work on pure Darwin because it does just barely use Cocoa for the SDL display, because fink's SDL doesn't work properly on MacOS. Hacktarux and friends just fixed dynarec!

This differs from the Cocoa port in that it has plugin support, it has dynarec, and Rice has been buggily ported! We actually fixed the problems with the uniqueness of Darwin's handling of shared objects.

It's only been tested on Intel MacOS at the moment. It appears to run at full speed on a 2GHz core2duo iMac.

Procedure:

* Download the mupen64 source: http://mupen64.emulation64.com/files/0.5/mupen64_src-0.5.tar.bz2

* Download our mupen64 patch:
http://smuckola.org/projects/mupen64/mupen64_src-0.5-darwin.diff

* Assuming you have xcode, fink, and xorg or the equivalent installed, start an xterm (not Terminal.app) and do this: cd mupen64_src-0.5-darwin ; cat ../mupen64_src-0.5-darwin.diff | patch -p1 && ./configure --prefix=/usr/local && make

* Download the Rice video source: http://emutalk.net/showthread.php?t=41037

* Download our Rice video patch: http://smuckola.org/projects/mupen64/RiceVideo610-darwin.diff

* Patch Rice similarly and copy the .so and .ini from its dir into mupen64's plugins folder.

* Start mupen64, enable dynarec mode, enable Rice or glN64, enable SDL audio. Possibly edit the jttl_audio.conf's buffer sizes to prevent audio skipping.

Current flaws:

* Rice-related bugs: colors are weird on some light sources, and textures are occasionally buggy/flashy/etc

* no input device at all, not even keyboard, with either the basic input plugin or the SDL input plugin. The SDL input plugin's conf screen crashes instantly. We hope it's possible to manually configure a file or something to enable keyboard controls, or that the cocoa port did something in the source, so then we can take over with USB Overdrive. Or maybe it'd magically work if we used Cocoa.

If you're wondering about the disabling of some of Rice's asm, Feanor says that some of the asm is totally redundant and doesn't do anything that the C output doesn't do. He says it doesn't define all its register clobbers (I hope you know what that means because I don't.) In general, a lot of the code has a lot of needless Linux-specifics so we hope that Hacktarux can incorporate some of this to make it more portable. The code also assumes that it's living on a case-sensitive filesystem in the case of Config.h whereas the default filesystem on MacOS is case-preserving/case-insensitive. I hope we can integrate this as a bunch of #ifdef or somesuch so that it's unified as one source base ASAP.

Here is a good guide on the basics of porting apps to Darwin.

http://www.finkproject.org/doc/porting/shared.php?phpLang=en

From what I've read in the archives, Hacktarux and friends made a valiant effort in about 2004, and if they'd had this guide, they'd have done a lot better because it is a pretty unique process. Darwin handles shared objects and dynamic libraries uniquely. You have to replace malloc.h with stdlib.h everywhere.

Okay so can someone please enable input support? ;)
 
Last edited:

Hacktarux

Emulator Developer
Moderator
We've worked really hard on a dynarec problem and we found out back than that it was a stack alignment problem. It should be fixed by replacing gennotcompiled function with the following code:
Code:
void gennotcompiled()
{
   free_all_registers();
   simplify_access();
   
   if (dst->addr == 0xa4000040)
     {
    sub_reg32_imm32(ESP, 0xC);
	mov_m32_reg32((unsigned long*)(&return_address), ESP);
	sub_m32_imm32((unsigned long*)(&return_address), 4);
     }
   mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst));
   mov_reg32_imm32(EAX, (unsigned long)NOTCOMPILED);
   call_reg32(EAX);
}
 

Mr VacBob

New member
The reason input doesn't work is because it runs plugins in a seperate thread. SDL needs to run in the main thread for OS X. Maybe we should just update the Cocoa port...
 
OP
D

dtm

New member
Oh hi there, Feanor. I can't think of any reason not to go to Cocoa, which would best serve the public! It'd be extra work to maintain the Darwin fork for inclusion in traditional Fink. Does it build on GNUStep? :) Do you think there would be any way to unify the ProjectBuilder codebase upstream so that it's no longer a fork, or is ProjectBuilder just too alien?

It'd be nice to have some explicit documentation on how to build it in ProjectBuilder because I have no experience there, and I couldn't get svn to build. It can't find MyOpenGLView.mm . I have no idea what that is and google is no help. If I could do that, I'd at least call more attention to the Cocoa port fwiw.

Can someone port the plugins? It'd probably be relatively straightforward, given what we did for the Darwin version.
 
Last edited:

Mr VacBob

New member
It looks like mupen/Rice have been cleaned up a lot lately. I might try to revive the native OS X port after finals; I don't think many people would be interested in figuring out X11/GTK+ to run it.

Though I'd be replacing the whole UI and possibly more (it might be easier to avoid SDL entirely than to make it all work in the main thread...), hopefully I could do it in sync with upstream.

(edit: I just mean the frontend and the various preferences here, I'd try to keep the emulation the same SDL code)

OS X can run x86-64 apps too, but we might as well stick to 32-bit as long as the dynarec only works there. You can always make it do register allocation!
 
Last edited:
OP
D

dtm

New member
Hey kids! Just a bookmark here to tell you that all MacOS porting effort has moved to another thread under Mupen64Plus!

http://www.emutalk.net/showthread.php?t=44434

If you want to help, read the whole thing and all other linked threads and come to irc. If you just wanna play, then just subscribe to the thread and listen for status updates, don't need to ask. Thanks so much!
 

Top