OpenEmu/OpenEmu — pull request #666 by conradev (2013-06-16 23:32:14+00:00)
Title: MAME Core for arcade machine emulation

I wrote a MAME core in its early stages for OpenEmu and wanted to open it up if anyone wants to help further it along. It needs a lot of work, but the basics are set up and in place. I don't expect this pull request to be merged (or at least, just yet), but I wanted to give you all a heads up. It is based on MAME 0.149 which was released a couple days ago on June 11.

### What works:

- Building MAME in Xcode (a feat in itself)
- Game execution
- Audio

### What doesn't work:

- Video
- Stopping game execution
- Game selection
- Pausing
- Save states
- Cheats

To get what I have up and running, it should be as simple as cloning my fork and building Grab a drink because MAME is *huge* and takes a while to build.

To address what already works - I put extra effort into getting MAME to build in Xcode, and tailored the Xcode project so that any changes at the project level cascade down to the target level. It is organized in the same way as MAME's own makefile based build system. The OSD (Operating system dependent) layer is based on POSIX/Mach and functions as it should. The OSD interface is a stub that maps directly to the core object. MAME is executed on a separate thread, and rendered on the usual render thread. I ensure the two threads sync up with an OSD 'event' (pthread condition lock). Audio is straightforward, the core just dumps the audio received from MAME into the audio buffer.

I plan on attacking video by rendering MAME's "primitives" (lines, quadrilaterals) directly to the OpenGL context at the native size of the game, and letting OpenEmu scale it up based on user preference. The rest of what doesn't work can be addressed by mapping methods on the game core to the `running_machine` object, and fixing any bugs in between. If you need help with any of the functionality, I would suggest looking at @clobber's [fork](https://github.com/clobber/MAME-OS-X) of Dave Dribin's MAME OS X. The code is messy, but it is all there. One issue that I have not solved is loading games. It is really expensive (multiple seconds) to identify the correct driver for a game based on the contents of its zip file. Most MAME emulators have a game selection dialog that lists every MAME game supported. Perhaps it would be possible have the user select the name of the game they believe their zip file is. Or game identification can run in the background somehow.

Excited to finally push this out into the open!