This forum is in permanent archive mode. Our new active community can be found here.

ClientServerMAME: Play MAME games on the net

edited August 2010 in Video Games
Hey guys,

Some of you might have heard of MAME (Multi Arcade Machine Emulator). Basically, it lets you play arcade games dating back from pong (or maybe even earlier) to arcade games circa 2006. The volume of games supported by mame is massive, and includes some consoles (notably, Super Nintendo).

There's a program called Kaillera that allows you to play MAME games online with your friends, but it has some drawbacks:
-It only works for windows
-It uses UDP and does not gracefully handle dropped packets. The games will desync and become frustrating for all players if a packet is dropped
-It isn't open source

So I decided to write my own network wrapper around MAME. ClientServerMAME supports any number of players (6-player X-Men anybody?), performs a complete game sync every 5 seconds to eliminate desync, works on any OS that MAME supports and even between OS's (I have been able to play a game between a windows 7 box and an ubuntu machine), and is completely open source ( http://github.com/MisterTea/ClientServerMAME ).

I've tested it myself using traffic controller to simulate internet lag, but I haven't tried playing any games on the net yet. Please let me know how it works and what the latency is like (not noticeable, unplayably laggy, etc.). What follows is the instructions for getting it up and running on windows (linux and intel osx versions are coming):

1) Find one or more friends (this can be the hardest part)
2) Both of you get the rom you are going to play and ClientServerMAME from here:

http://www.underworldhockeyclub.com/ClientServerMAME/ClientServerMAME_v0_1_Win32.zip

3) Decide who is going to be the server
4) The person who is the server needs to make sure that TCP port 5805 is open and points to their IP. This will probably require port forwarding or something like that. Most games have this issue, so you can find info on it on the internet if you need help.
5) The server needs to tell everyone else his IP address or hostname
6) Have the server start the game like this:
mamesdl.exe (rom) -server
7) Have the clients connect like this (make sure you fill in (rom) and (hostname) with real values):
mamesdl.exe (rom) -client -hostname (hostname)
8) Everyone uses player 1 controls on their own machine. ClientServerMAME currently does not support having more than one player at a single computer, and all other player inputs are ignored.
9) There isn't much in the way of error handling at this point, so don't do anything stupid like try to run a different rom on the client as the server or try to load a rom while you are in the middle of another game or it will crash hard.

Let me know what you think. My plan is to pass this out to some friends and play some beat-em-ups, but if people find it useful I will add more features like having servers report to a master server so people can host public games.

Comments

  • Oh, wow. That's really cool. I know that most emulators with network play have sync issues because they send the player inputs over the net, and if the player inputs don't arrive with precise timing, that is how the sync is lost. When ClientServerMAME syncrhonize the player inputs, or is it actually synchronizing the state of the game?
  • edited August 2010
    Oh, wow. That's really cool. I know that most emulators with network play have sync issues because they send the player inputs over the net, and if the player inputs don't arrive with precise timing, that is how the sync is lost. When ClientServerMAME syncrhonize the player inputs, or is it actually synchronizing the state of the game?
    Well, in the case of MAME, you are running a virtual machine and are in complete control of the timing of that machine. So you can process the input at specific times in the virtual machine and pause the game if you are missing an input. Kalliera can still desync though because if they drop a UDP packet, they don't wait and request the missing packet, but continue processing and assume the client didn't hit any buttons that frame. Both Kalliera and ClientServerMAME will desync because two different processors can produce different floating point results. This problem is magnified when you also throw in different compilers and different architectures (32 vs 64-bit). ClientServerMAME syncs the player inputs for the majority of the time, but every 5 seconds performs a complete game sync by having the server perform a state save and sending it to the clients, who perform a state load. It all happens so fast that if the games were in sync before, no one will notice.

    Oh that reminds me, the games must support save states. At this point, almost every game does, but there are still some exceptions.

    I'm currently using TCP because I didn't want to add UDP issues to the mix of things to debug, but I will switch to UDP once this version has been tested some. Unless you are playing street fighter II turbo or trying to play a game between the US and Europe, UDP is overkill anyways. I'll need people to test the current implementation and give me feedback to know more.
    Post edited by DigitalGhost on
  • I have regular old MAME going on my HTPC, so it shouldn't bee to much trouble to test this out. I just need somebody to test with.
  • edited August 2010
    I have regular old MAME going on my HTPC, so it shouldn't bee to much trouble to test this out. I just need somebody to test with.
    Some friends and I are testing right now if you are around. I already fixed some bugs and I'm putting new verisons on github here:

    http://github.com/MisterTea/ClientServerMAME/downloads

    So far I still have some bugs to fix. The biggest one is that the server uses blocking writes, so the 3rd/4th/... players get screwed as far as ping since it sends to the 2nd player before them. I'm going to have to change it to async writes for more than 2 player games.

    Another bug is that it uses TCP and waits for all packets to come in, so if someone is dropping packets, it slows everyone down.
    Post edited by DigitalGhost on
  • I switched to asynchronous UDP and also added support for MESS, which means players should be able to play console games in addition to arcade games. Going to try some goldeneye64 this weekend. I'll let you know how it goes.
  • Awesome. Would be sweet to play gigawing and donpachi online
  • edited August 2010
    You can grab the latest ClientServerMAME and ClientServerMESS here: http://github.com/MisterTea/ClientServerMAME/downloads

    I've tested MAME with a few arcade games and MESS with a few snes games and it seems to work ok, but planning on playing more over the weekend.

    To use ClientServerMESS:

    Server:
    messsdl.exe (system) -server -cart (full path to rom)

    Client:
    messsdl.exe (system) -client -hostname (hostname) -cart (full path to rom)

    NOTE: You need both tcp and udp port 5805 forwarded for this to work.

    Example:

    messsdl.exe snes -server -cart "c:\Roms\SNES\FinalFight3.smc"

    messsdl.exe snes -client 123.123.123.123 -cart "c:\Roms\SNES\FinalFight3.smc"

    EDIT: To play MESS, you need to download the BIOS for whatever system you are using. You can find it with a google search.
    Post edited by DigitalGhost on
  • edited August 2010
    New version of ClientServerMAME on the website.

    We played SmashTV and Super Contra with 2 players, and WWF Wrestlefest with 4 players, ran smooth. I think that this version is ready for prime time.

    There are still some TODOs but they are mostly cosmetic:

    -Compress the initial game state when a client first conencts
    -Work inside of the MAME UI or a mame frontend so you don't have to use command line options
    -Have a way to list what IPs are connected and playing

    Anyways, been playing arcade games until 3am, I'd say it's time for bed :-P
    Post edited by DigitalGhost on
  • Hey all,

    I posted ClientServerMESS on the ClientServerMAME downloads page, and posted linux binaries (mac is still coming, but giving me trouble).

    I played some super mario kart last night and it worked fine except for me doing terrible and getting my ass kicked in battle mode for 3 hours. We decided to start posting some youtube vids to show how to get it running in case the instructions aren't clear enough, I'll let you guys know when the vids are up.
  • edited August 2010


    6-player X-Men anybody?
    Haven't run MAME in a few years, but I remember there being an issue with the X-Men Arcade ROMs where they could not accurately get the music out of the game, and it was replaced by whoever made the ROM. Would love to know if this is false or if someone has overcome the issue in the meantime. Any info?
    Post edited by Matt on
  • edited August 2010
    Hey guys,

    Version 0.6 of ClientServerMAME and ClientServerMESS are out on windows. There's a bug in the SNES emulator that causes the video to freeze on clients on startup, but after a few seconds, the video unfreezes. Also, if you go into mode7, the video unfreezes. I have a post on the MESS forums so hopefully it well get resolved. This version also has fixes for NES

    Played double dragon 2 tonight, went well other than a few screens were glitched on my computer but fine on my friends' comp.
    Post edited by DigitalGhost on
  • We should play some elevator action 2 on MAME. It kicks.
  • We should play some elevator action 2 on MAME. It kicks.
    There's a second Elevator Action?
  • edited August 2010
    We should play some elevator action 2 on MAME. It kicks.
    There's a second Elevator Action?
    Someone made a game and named it Elevator Action?
    Post edited by Sail on
  • We should play some elevator action 2 on MAME. It kicks.
    There's a second Elevator Action?
    Someone made a game called Elevator Action?
    Games?
  • We should play some elevator action 2 on MAME. It kicks.
    I tried a few levels, looks pretty cool. I'm down for some elevator action 2 online, let me know what time.
  • I tried a few levels, looks pretty cool. I'm down for some elevator action 2 online, let me know what time.
    I'm good the rest of tonight, but I need some time to setup the technology.
  • There's a second Elevator Action?
    Someone made a game called Elevator Action?
    Games?
    Sweet jebus you three know how to make a guy feel ancient.
    /played them both at the arcade during his formative years.
  • I tried a few levels, looks pretty cool. I'm down for some elevator action 2 online, let me know what time.
    I'm good the rest of tonight, but I need some time to setup the technology.
    Oops, wasn't monitoring the forums and missed your post. Is there a way to subscribe to the topic and get emails when someone posts?
  • Oops, wasn't monitoring the forums and missed your post. Is there a way to subscribe to the topic and get emails when someone posts?
    No, but each thread has its own RSS feed. Didn't matter anyway. I was doing work and didn't have time to configure the software.
  • Hey all, CS-MAME & CS-MESS 0.6 are out. Here are some of the changes:

    -Support for the native mame/mess build systems. This fixes several bugs and adds support for OS/X
    -Fixed issues with compression of large save states
    -Fixes for NES and SNES save states. There are still glitches, but most games are playable
    -Gracefully exit upon network failure
    -Changed makefiles to support creation of debian packages (added "make install" feature)

    You can find the code and binaries (windows, linux, mac) here:

    http://github.com/MisterTea/ClientServerMAME/downloads
  • edited September 2010
    Hey all,

    I've been continuing to release updates and improve the netcode. I also released a video with step-by-step instructions on how to set it up and play.

    You can check it out here: http://www.youtube.com/watch?v=be1_3Lp0xq0
    Post edited by DigitalGhost on
Sign In or Register to comment.