Configuring MythGame Emulation

From MythTV Official Wiki
Revision as of 18:45, 18 August 2006 by Mrsdonovan (talk | contribs) (Moved joystick information into the new joystick section)

Jump to: navigation, search

Introduction

These instructions are specific to MythGame v0.19. (MythGame 0.18 instructions may be found here.) This document covers configuration of MythGame after it is installed; compilation and installation are not covered.

Note that the term player refers to the emulator software (ie, xmame) and not the human playing the games.

ROM Layout

MyhtTV categorizes your ROMs by system type (NES, SNES, etc). It also requires a path to provide to each emulator. Thus it's desirable to store your ROMs in separate directories based on the system. An example directory structure is given below. Your structure may differ but separation by system type is key.

/usr/emulators/nes/roms
/usr/emulators/snes/roms
/usr/emulators/gba/roms
/usr/emulators/n64/roms
/usr/emulators/amiga/roms
/usr/emulators/amiga/chip   (For the Kickstart Image)
/usr/emulators/atari_lynx/roms
/usr/emulators/megadrive/roms
/usr/emulators/xmame/roms

ROM Descriptions

MythGame allows you to provide titles, descriptions, screenshots, release year, and other information for your ROMs. This information can be automatically detected by matching CRC values. For automatic detection the romdb must be populated. This appears to be done by default; however, you can find an SQL load script in the v0.19 source packages as romdb-20051116-02.tgz. Or you can grab the a similar file from [1]. Untar and load:

tar -xzvf romdb-20051116-02.tgz
mysql -D mythconverg -u mythtv -p < romdb-2005-1101-01.sql

If running the above reports errors it's likely because the SQL file includes commands to create romdb table and your system already has the romdb tabe. Try removing the following lines from .sql file and re-running the above mysql command: CREATE TABLE romdb ( ... ) TYPE=MyISAM;


MythGame 0.19.0-Specific Note

On at least one reported system MythGame v0.19.0 was failing to load from the romdb table because of a code error in MythGame's gamehandler.cpp. The fix is to delete the trailing space in the SELECT statement in InitMetaData(). Change this:

QString thequery = QString("SELECT crc, category, year, country, name, "
                           "description, publisher, platform, version, "
                           "binfile FROM romdb WHERE platform = \"%1\"; ")
                           .arg(GameType);

To this:

QString thequery = QString("SELECT crc, category, year, country, name, "
                           "description, publisher, platform, version, "
                           "binfile FROM romdb WHERE platform = \"%1\";")
                           .arg(GameType);

Screenshots

When looking for screenshot files, Mythgame first strips the file extension by chopping off everything after the last . (dot) in the filename (of the game in question). It then cycles through this list of image format extensions to see if appending any of those result in an existing file (in the screenshot directory):

  png
  gif
  jpg
  jpeg
  xpm
  bmp
  pnm
  tif
  tiff

Note that it is stripping the file extension from the filename, which means that the screenshot filename has to be exactly the same (minus the extension). In case of games with multiple disks, this implies the disk number should also be included in the screenshot filename. However, Mythgame currently does not seem to consistently pick the first disk of a game. For more details, see | ticket

Generated Screenshots

A new | ticket provides a patch for MythGame that allows you to generate screenshots for the ROMS automaticaly within MythGame.

It uses the program scrot to generate screenshots of your X display.

It has also a patch included wich delays the loading of the screenshots about 300 msec so that scrolling through the roms goes as fast as without the screenshots.

Emulators

Each emulator (called player within MythTV) must be setup individually. Setup consists of specifying a name, the type of hardware being emulated, the binary to execute, and the location of the roms.

If the path to the emulator binary is in your PATH there's no need to specify it in the setup. To determine which path a program is installed run which <program>.

Most emulators are included with OS distributions. Consult your package manager (rpm, dselect, emerge, synaptic, etc) before installing from source (unless you have a specific reason to do so).


Nintendo: SNES

ZSNES

Homepage: http://www.zsnes.com/

Version: 1.42

ZNES requires a mouse for configuration in the GUI, keyboard support is not fully implemented. Fortunately the configuration only has to be done once.

Start ZSNES to create the config file. I recommend setting the option 2x Super SAI Engine under Configuration > Video so the picture looks smoother. After configuring ZSNES and exiting you must copy the configuration (by default ~/.zsnes) to the mythtv user directory (probably ~mythtv/.zsnes).

NOTE: (Current as of 06/20/2006) FC5 users may encounter issues compiling the 1.42 version. Consider getting the CVS version from SourceForge.

Add a new player in MythGame's setup:

Player Name: SNES 
Type: SNES 
Command: zsnes 
Rom Path: /usr/emulators/snes/roms

SNES9x

Homepage: http://www.snes9x.com/

Version: 1.43

An alternate SNES emulator is called SNES9x. The quality of this emulator is near to ZSNES, if not better. It has no frontend on Linux but frontends just get in the way on MythTV. Everything can be configured through the command line, and most options work for all games, so once you have it set up you only need to modify command line options when you change hardware, like joysticks.

To view the configuration options run snes9x -h.

On many linux distributions to utilize full screen mode in SNES9x you need to add the SUID bit to your SNES9x binary. This is a security risk, but it makes games much more enjoyable. To add the SUID bit, do this:

 chmod 4750 `which snes9x`

Please adjust group and world permissions as necessary to suit your distribution.

Add a new player in MythGame's setup:

Player Name: SNES 
Type: SNES9X 
Command: snes9x -stereo -r 6 -tr -fs
Rom Path: /usr/emulators/snes/roms

DGA Support On Newer NVIDIA Drivers

SNES9x uses an extension of X called DGA when using full-screen mode. DGA allows applications direct access to the video frame buffer. The latest set of NVIDIA drivers does not support DGA, and if you try to run SNES9x using full-screen mode, it will fail. The README file for the latest NVIDIA drivers explains this.

Nintendo: NES

fce-ultra

Homepage: http://fceultra.sourceforge.net/

Version: 0.98.13

Start fceu with fceu -inputcfg gamepad1 %romname% to configure your joystick. In XWindows, the executable may be fceu-sdl instead of fceu.

Add a new player in MythGame's setup:

Player Name: NES 
Type: NES 
Command: fceu --fs 1 --joy1 1 --xres 1024 --yres 768
Rom Path: /usr/emulators/nes/roms

Nintendo: Game Boy Advance & Game Boy

Visual Boy Advance

Homepage: http://vba.ngemu.com/

Version: 1.80 SDL

The latest cvs version is recommended though older binaries do work. To get the latest cvs version run cvs -z3 -d:pserver:anonymous@vba.cvs.sourceforge.net:/cvsroot/vba co -P VisualBoyAdvance

Then we need to go into the VisualBoyAdvance directory and run: ./configure

After that we do: make

And then after compilation has completed we can copy the VisualBoyAdvance binary from the source dir to our binary directory (ie /usr/local/bin/).

You then need to edit the VisualBoyAdvance.cfg to edit your Joystick settings. If you want to change it, you can get a program called SDL Configurator from the VisualBoyAdvance downloads page to get the correct settings for your joystick: http://vba.ngemu.com/downloads.shtml

Add a new player in MythGame's setup:

Player Name: GBA
Type: OTHER 
Command: VisualBoyAdvance -F -4 (or -3, or -2 depending on your screen size, whatever works best for you)
Rom Path: /path/to/gba/roms

(The Parameters -F runs the emulator in a full screen and -4, -3, or -2 enlarges the picture x4, x3, or x2 respectively. Experiment to see which one fits your screen the best.)

Note: if you cannot get VisualBoyAdvance to compile, your best bet for Fedora Core 4 is to install this: http://vbaexpress.tuxfamily.org/visualboyadvance-1.7.2-1.FC4.i386.rpm


Mednafen

Homepage: http://mednafen.com/

Version: 0.6.2

Mednafen is available with Debian official, and therefore many of the derived distros using Apt. The official page only has source code available, so check with your distributions repositories if you don't use Debain/Derived or make sure you have up to date SDL libraries if you intend to compile it yourself.

Player Name: Mednafen
Type: OTHER
Command: mednafen -gba.stretch 1 -fs 1 -vdriver 0 %s  (vdriver 0 is for OpenGL, if you prefer SDL surface blits use 1)
Rom Path: /path/to/gba/roms


Nintendo: N64

Mupen 64

Homepage: http://mupen64.emulation64.com/

Version: 0.5

You must compile Mupen from source because the binary versions do not include the nogui version.

Download Mupen source by running wget http://mupen64.emulation64.com/files/0.5/mupen64_src-0.5.tar.bz2. Then extract the source.

Configure Mupen with ./configure

libSDL-devel is required to compile Mupen. See http://www.libsdl.org/.

Mupen64 0.5 comes with a bug which results in the nogui version not compiling. To fix this, edit main/main.c and insert the following at the beginning of the file:

#include <dirent.h>
#include <sys/stat.h>

Compile the Mupen nogui Version with: make mupen64_nogui

Now you need the MUPEN Plugins. You can also compile them or get them within the binary distribution of the Mupen Webpage (the latter is much easier and recommended).

Create a config file to use with Mupen. An example file follows:

mupen64.conf

[Default]
Gfx Plugin = /usr/emulators/n64/bin/plugins/Glide64.so
Audio Plugin = /usr/emulators/n64/bin/plugins/jttl_audio.so
Input Plugin = /usr/emulators/n64/bin/plugins/blight_input.so
RSP Plugin = /usr/emulators/n64/bin/mupen64_hle_rsp_azimer.so
Fullscreen = true
Emulation Mode = 2
No Ask = true

Add a new player in MythGame's setup:

Player Name: N64
Type: N64
Command: mupen64_nogui
Rom Path: /usr/emulators/n64/roms


Commodore: Amiga

E-UAE

Homepage: http://www.rcdrummond.net/uae/index.html

Version: 0.8.29

This emulator is a backport to linux from WinUAE.

Add a new player in MythGame's setup:

Player Name: Amiga
Type: AMIGA 
Command: /usr/emulators/amiga/bin/uae -s floppy0=%d1 -s floppy1=%d2 -s floppy2=%d3 
-s floppy3=%d4 -s  floppy_speed=800 -s kickstart_rom_file=/usr/emulators/amiga/chip/KICK31.ROM
-s gfx_fullscreen_amiga=true -s use_gui=false
Rom Path: /usr/emulators/amiga/roms
Span Disks: yes

(Note: the command is a single line; it is split here so it fits on the screen.)

X-Fellow

Homepage: http://sourceforge.net/projects/xfellow

Additional details needed.

Origanal UAE

Homepage: http://sourceforge.net/projects/uaedev/

Version: 0.8.23

Additional details needed.


Atari: Lynx

Handy SDL

Homepage: http://sdlemu.ngemu.com/sdlemu/handysdl.php

Version: 0.82 R1

You also need a BIOS image from the Atari Lynx. Copy this into the directory with the emulator's binary. (Info: You are only allowed to use a BIOS dump of your own Lynx machine!)

Player Name: Atari Lynx
Type: OTHER 
Command: sdyhandy %s -fullscreen -scale 4 -sound -joystick
Rom Path: /usr/emulators/atari/lynx/roms


XMAME

Homepage: http://x.mame.net/download.html

Version: 0.106

Install xmame from source or your distro's binary installer

All xmame settings can be controlled from the ~/.xmame/xmamerc file. You might have to play around with your xmamerc (or in the case of the SDL version, xmame-SDLrc). See the xmame docs. Run xmame with --showconfig to see your current configuration. At a minimum, set the following:

video-mode              1
fullscreen              1
sound                   1
skip_disclaimer         1
skip_game_info          1

### set the following to the actual paths to your xmame files
rompath                 /usr/emulators/xmame/roms          #zipped rom images from arcade games
cfg_directory           /home/mythtv/.xmame/cfg        #files to store joystick setup per game
nvram_directory         /home/mythtv/.xmame/nvram      #in game setting and highscore data
memcard_directory       /home/mythtv/.xmame/mem        #memory card directory for games that use it
hiscore_directory       /home/mythtv/.xmame/hi         #highscore data per game
snapshot_directory      /usr/emulators/xmame/snap          #directory for screenshots
cheat_file              /usr/emulators/xmame/cheat.dat
hiscore_file            /usr/emulators/xmame/hiscore.dat
history_file            /usr/emulators/xmame/history.dat
mameinfo_file           /usr/emulators/xmame/mameinfo.dat

### if using a joystick
joytype                 1
analogstick             1
### set to the name of your js device
joydevname              /dev/js
### to enable mouse support
mouse                   1

The above paths should be changed to reflect the paths on your system. You can download cheat.dat (unlock some game cheats), hiscore.dat (save game highscores between playing), history.dat (show tips / tricks / and game histroy in the user menu), and mameinfo.dat (shows emulation information in the user menu) files to unlock their features in mame. These files can be downloaded from links at www.mame.net

Remember to place the .zip files for your ROMS into your roms directory. Do not unzip them, MythGame will scan for the game names in your roms folder and add them correctly to MythGame. For your screenshots to appear correctly, make sure they have the same name as the mame rom.

With all your paths setup, test xmame at a prompt:

xmame <romname>

If all goes well, xmame should start fullscreen with the rom you specified. Verify that all the controls work, and you hear sound. If something does not work, review your xmamerc file, the path information above, and read the xmame docs and the Mame FAQ.

When satisified, configure MythGame as follows:

Player Name: XMAME
Type: MAME 
Command: xmame %s
Rom Path: /usr/emulators/xmame/roms

Answers to questions related to how to play mame can be found here: http://www.mame.net/mamefaq.html

Sega: MegaDrive/Genesis

DGENS/SDL

Homepage: http://pknet.com/~joe/dgen-sdl.html

Version: 1.23

Note: compiling of the source from the above website has failed on at least one system. Using your distribution's packaged version is highly recommended.

Player Name: MegaDrive
Type: OTHER 
Command: dgen -f -G 800x600 -j
Rom Path: /usr/emulators/megadrive/roms

PSX

ePSXe

Homepage: http://www.epsxe.com/

Version: ?

Install for linux is straightfoward when one follows this howto.

To make this work with MythGame a few changes have to be made:

The script suggested at step 10 needs a slight modification:

change this line -- ./epsxe to this -- ./epsxe -nogui -loadiso $1

This will allow you to run iso/bin files from within MythGame, however, it won't work for loading cds.

In addition, to get nice fullscreen, I found it better to set the resolution to your screens resolution worked better than choosing fullscreen.

Finally, do look into using the joypad plugin. This is especially true if you will be using a joystick.

Player Name: ePSXe
Type: OTHER 
Command: /usr/local/bin/start_epsxe
Rom Path: /usr/emulators/ps1/roms

More Emulators...

Following are alternate emulators. Additional instructions are encouraged so if you get one of these working please update this document.

PSX:

GameBoy:

DreamCast

Multiple Systems

  • Xe Game Boy, MegaDrive, Super Famicom, PC-FX, Playstation, GameGear, ...
  • Mednafen Atari Lynx, GameBoy, GameBoy Color, GameBoy Advance, NES, PC Engine(TurboGrafx 16), and SuperGrafx
  • [2] Xmess (Many Sytems...)


Remote Control Integration

It's very convenient to use your remote, and not a keyboard, to exit an emulator in MythGame. Most of the emulators do not support lirc natively. They also will not work with lirc's irexec because the emulators use SDL, ignoring all X11 key events. Fortunately through a combination of programs it's possible to have your remote trigger SDL key events the emulators respond to.

The instructions below pertain to specific emulators. The process is easily extended to other emulators though. Two examples are provided to aid understanding.

Note: irexec is used to invoke an external command. Thus you can not use irexec to control MythTV; instead use MythTV's native support for lirc.

Base Requirements

xmacro can send events understood by SDL programs (such as the emulators). It's xmacroplay-keys program is used to send an escape key event. You must install it; check your distribution for a precompiled package (ie, apt-get install xmacro).

lirc's irexec is used to capture remote events and invoke xmacroplay-keys. Add the following to your .lircrc:

   begin
   prog = irexec
   button = Exit
   repeat = 0
   config = xmacroplay-keys :0 Escape
   end

Note: change the above Exit button to whatever mapping/button you want to use on your remote to exit the emulator.

irexec can't be running all the time or it and MythTV will respond to remote events causing Escape to be invoked inside MythTV twice. So instead start irexec immediately before running an emulator and kill irexec when the emulator exits. The scripts below do exactly this.


Another possible Option is that you create a Script wich kills all your emulators like:

emukill.sh

   #!/bin/sh
   
   killall mupen64_nogui
   killall zsnes
   killall fceu

then you add to your to your .lircrc:

   begin
   prog = irexec
   button = Exit
   repeat = 0
   config = emukill.sh
   end

with this option you don't need to create a script for every emu, only one to kill the emu's. But be aware, not every emu can be exited so, but you can try to add a -9 to killall wich exits the emu in every case. Also, killing an emulator instead of exiting it will often result in saved game data not being saved to disk.

ZSNES

Enter the following script as snes.sh:

   # zsnes path + executable
   ZSNES=/usr/bin/zsnes
   
   # irexec path + executable
   IREXEC=/usr/local/bin/irexec
   # irexec process name to kill
   IREXEC_PS=irexec
   $IREXEC &
   $ZSNES -m "$1"
   killall $IREXEC_PS
   
   exit 0

Adjust the paths and executables along with any arguments to zsnes (-m above). In the MythGame player's setup invoke the above script instead of zsnes directly.


NES

Enter the following script as nes.sh:

   # fceu path + executable
   FCEU=/usr/games/fceu
   # irexec path + executable
   IREXEC=/usr/local/bin/irexec
   # irexec process name to kill
   IREXEC_PS=irexec
   $IREXEC &
   $FCEU -fs 1 -input1 -gamepad -no8lim 1 "$1"
   killall $IREXEC_PS

Adjust the paths and executables along with any arguments to fceu (-fs 1 -input1 -gamepad -no8lim 1 above). In the MythGame player's setup invoke the above script instead of fceu directly.

Xmame

The xmame project has supported lirc natively since version 0.90. Unfortunately xmame only understands keymap values. For instance, the Escape key has a keymap value of 1. Entries will need to be added to your .lircrc file as follows:

# Esc - exit
begin
prog = xmame
button = Back-Exit
repeat = 0
config = 1
end

You can view the keymap values in the xmame source (xmame-<ver>/src/unix/keycodes.h) Some example keys that would be useful to map to a remote key are below

key   keycode  function
ESC   1        Exit Emulator
UP    103      Navigate GUI
DOWN  108
LEFT  105
RIGHT 106
1     2        Start Player 1
2     3        Start Player 2
5     6        Add Coin Player 1
6     7        Add Coin Player 2
Tab   15       Open in game menu GUI
Enter 28       OK/Enter in menu
P     25       Pause game
F3    61       Reset game
~     41       OSD for Volume, gamma, etc.
F9    67       Increase Frame Skipping
F8    66       Decrease Frame Skipping
F11   87       Show/Hide Frame Skipping info

Note: In practise, a remote is too slow to play arcade games but it is useful for exiting the emulator with the (ESC) or back key.

  • Set "lirc 1" in xmamerc
  • Edit your .lircrc file to add entries for xmame.

Joystick or Gamepad Integration

Linux has support for gamepads and joysticks through the joydev driver which usually comes standard with most distros. There are useful utilities that can be installed with "yum install joystick" to calibrate joysticks, etc.

xMame

There are 5 joystick types for the joytype switch in xmamerc as of version 0.88

  • 0 No joystick
  • 1 Linux i386 joystick (version 1.x.x)
  • 2 Town Pad gamepad
  • 3 BSD USB joystick
  • 4 PS2 joystick
  • 5 SDL joystick interface

Nintendo: SNES

SNES9x

If you are interested in using SNES9x with a joystick, please read about the -joydev and -joymap command line options. In addition, if you have the luxury of building snes9x from source, Reboot's joyaxisX patch is an excellent and necessary addition to the program.

The Gravis GamePad Pro correctly maps as follows:

 -joydev1 /dev/js0 -joymap1 2 1 3 0 4 5 9 8

This assumes that your GamePad Pro mounts at /dev/js0. Use $ls dev/j* to confirm where your joystick mounts inside your build.

Nintendo: Game Boy Advance & Game Boy

Visual Boy Advance

You then need to edit the VisualBoyAdvance.cfg to edit your Joystick settings. If you want to change it, you can get a program called SDL Configurator from the VisualBoyAdvance downloads page to get the correct settings for your joystick: http://vba.ngemu.com/downloads.shtml

Mednafen

Joystick configuration is both easy and confusing at the same time. Once you have the emulator running his the F3 key, you should get a prompt for button A that looks like this:

pad: A (1)

Simply hit the button on your control pad that you want to be button A. You will then get a prompt for button A on another control pad, this is where it can get confusing. If you don't want to setup another button on your keyboard or another/same control pad wait a couple of seconds and hit your button for A again, it should progress to B, if not wait another second or two and hit your button for A another time. Be patient and you'll get used to the input method. You can program up to four control pads this way. All the buttons (including directional) are accounted for this way, plus two buttons for rapid fire. Mednafen should remember your settings next time you enter the program.

List of Gamepads and Joysticks

Manufacturer Model # Linux Distro drivers required Works with: Comments
Logitech Wireless Rumblepad 2 FC3 & 5 usb, joydev xMame Setup was easy, "modprobe joydev", plugin in the gamepad receiver and check to see it was regcognized by a "Rumblepad 2" line in the /var/log/messages file. Then cat /dev/input/js0, move a stick, and see if gibberish (### # 3# #### #) is printed. Then in xmamerc, "joytype 1", "analogstick 1", "joydevname /dev/input/js0" (or /dev/input/js if you have multiple joysticks). Once in xmame, hit TAB to redefine the keys to the joystick keys (hit enter and hold the joystick button until recognized). The rumblepad had two joysticks which can be used by different players. Calibration wasn't needed and xMame doesn't support vibration. I haven't tried other gamepads, but the rumblepad is very responsive with lots of buttons for extras (like pause, etc.)
(Please add your example Hardware stats here!)