Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

Wednesday, June 19, 2013

Tutorial - Recording Videos of Games under MAME

I include a video of myself playing some video game in almost every one of my posts. In addition to the videos I share here, I have a YouTube page where I have 19 videos as of this writing. You might be wondering how I record these videos. In this tutorial, I will explain different methods that can be used to record videos while playing some arcade game on MAME.

The methods that I will discuss will use MAME's built-in "-mngwrite" and "-aviwrite" options and therefore, will not require any additional software (though some additional software may be necessary for processing the video and audio files generated by MAME). I will just mention that there are software which can be used to capture videos from the screen. This process is called screencasting. These programs, such as FRAPS, will record anything you see on screen as opposed to MAME's built-in functions which only record the game screen. In other words, if you press the TAB button to access the options menu, this menu will be a part of the video that FRAPS records but the MAME video will not show this screen. My personal recommendation is not to use FRAPS or any other additional software unless the built-in functions of MAME do not work.

The options "-mngwrite" and "-aviwrite" tells MAME to record the output to a .mng and a .avi file respectively, but the common practice is not to use these commands while playing the game. The reason for this is that these commands, especially "-aviwrite", slows the system down considerably, sometimes to a point where it becomes impossible to play the game. A simple remedy for this problem is to record the input while playing the game and use the record commands while playing this recorded input.

MAME is capable of recording the user input and later playing these recorded input files. In other words, it is possible to create a replay file which contains all the moves you make while playing the game and can later be used to playback the entire recorded game. This is achieved using the "-rec" command. The usage is as follows:

mame -rec <filename>

To playback a recorded game, the "-pb" command is used in the following way:

mame -pb <filename>

Let me illustrate the usage of these commands on an example. Suppose a 64-bit version of MAME is installed in the directory " c:\mame" and you would like to play the game "Hard Hat" and record the input to a file named "input_rec.inp". The command you should enter is the following:

c:\mame>mame64.exe hardhat -rec input_rec.inp

This will create a file "input_rec.inp" in the "c:\mame\inp" directory. If you want, you can edit "mame.ini" file to change where the recorded input files are saved. To playback the recorded file, the following command should be entered:

c:\mame>mame64.exe hardhat -pb input_rec.inp

After entering this command, MAME will look for the "input_rec.inp" file in the "c:\mame\inp" directory and start the replay if this file is found. If this file is in some other directory, then you should enter the filename with the full path.

If there are problems with recording and replaying, you can try deleting the .cfg that belongs to whichever game you are playing. You should delete this file before recording and before the playback. This file is located in the "c:\mame\cfg" directory and the name of the file is the same as the name of the rom of the game. In the above example, the .cfg file will be "c:\mame\cfg\hardhat.cfg". You should also make sure that your version of MAME is the same as the version that was used to record the game.

After recording your input, you can use the "-mngwrite" command to write the recorded game to a .mng file, though it is claimed that this command stopped working on the newer versions of MAME. In addition, this command does not record any sounds from the game. Therefore, the "-mngwrite" command is usually accompanied by the "-wavwrite" command. The usage for these two commands is as follows:

mame -mngwrite <filename> -wavwrite <filename>

The files that were created by this command, by default, will be saved to "c:\mame\snap" folder. This, in addition to any other folder that MAME uses, can be changed by editing the "mame.ini" file in the "c:\mame" directory. You can also turn on/off recording of .mng videos by pressing SHIF + F12 anytime during the game, though with this method you will not be able to record any sound.

These commands can be used together with the "-pb" command. For example, suppose we want to make a video of the game "Hard Hat" from the recording "input_rec.inp" where the name of the video file is "video.mng" and the name of the audio file is "audio.wav". The command that we should enter is the following:

c:\mame>mame64.exe hardhat -pb input_rec.inp -mngwrite video.mng -wavwrite audio.wav

Now, after the playback, the files "video.mng" and "audio.wav" will be saved to the folder "c:\mame\snap". You can then use additional software to combine the audio and video files. There are free software that can be used for this purpose, such as MPlayer. I am not going to be able to offer any help about how to use this program, as this is not usually the method that I use to record my videos.

An easier way to record videos is to use the "-aviwrite" command. Unlike the "-mngwrite" command, the "-aviwrite" command will record both video and audio. The usage of this command is similar to the "-mngwrite" command:

mame -aviwrite <filename>

The files created with this command are saved to the "c:\mame\snap" directory as usual. For example, if we want to make a video of the game "Hard Hat" from the recording "input_rec.inp" where the name of the video file is "video.avi", the following command should be entered:

c:\mame>mame64.exe hardhat -pb input_rec.inp -aviwrite video.avi

After the playback, the file "video.avi" will be saved to the folder "c:\mame\snap". The avi files created by MAME are uncompressed and therefore they are extremely large (about 1gb per minute). You might want to compress these files, especially if you want to share these videos on Youtube or some other website. A free software that can be used for this purpose is Handbrake.

Finally, I will remark that throughout the tutorial, the assumption was that you are using the command line version of MAME, though user interface versions of MAME are also capable of recording and replaying game input and writing video and audio files; however I could not find a way to playback some recorded game and write a video file at the same time. In fact, that was the reason I started using the command line version.

Sunday, April 14, 2013

Tutorial - Playing Arcade Games at Home

The arcades of the 90's may have long gone out of business, but it is still possible to play those games at home. I am not talking about buying arcade machines, fortunately there is a more practical way. I am not talking about SNES or equivalent home gaming systems either; while some games do have SNES versions, not all arcade games are available in any other format, not to mention SNES versions of arcade games usually differ from the arcade versions. I am talking about playing arcade games on personal computers, with the help of software that emulates the CPU of an arcade machine. Unlike the SNES or other versions, games that are played on these emulators will be exactly the same as their arcade versions.

Though it is possible to find a number of examples for arcade machine emulators, MAME is undoubtedly the most popular choice among arcade gaming enthusiasts. We will focus on MAME in this article, leaving the reader to explore the other alternatives.

The MAME (which stands for Multiple Arcade Machine Emulator) Project is defined on its website as "a strictly non-profit project whose main purpose is to be a reference to the inner workings of the emulated arcade machines, both for educational and preservation purposes". Its first public release was in 1997 and as of version 0.147, it supports 26336 ROM sets with 8726 unique games (according to this data).

The first step of playing games with MAME is to download the program. For Windows, it can be downloaded for free from the project website, http://www.mamedev.org/. There are different options for download, such as 64-bit, i686 optimized etc., you should get the best choice for your system. For other operating systems, there are ports of MAME to Mac OS X, Linux and other operating systems/devices. The website for these ports can easily be found by googling "MAME <operating system name>". There is also a graphical user-interface version of MAME, called MAMEUI (formerly MAME32) for those who don't want to use the command-line version. For this article, we will restrict ourselves to the (64-bit) command-line version, however the principles are more or less the same for every version of MAME. We note that for advanced users, it is also possible to download the source code from the same webpage.

After downloading the program (as of present, the latest version is 0.148), run the exe file and it will extract the files to a folder of your choice, no further installation is necessary. In this tutorial, we will assume that MAME is placed on "c:\mame". To be able to play games though, you still need the data files for the game you want to play, which are known as ROMs. A word of copyright caution is due at this point. Although the MAME software is free, the ROMs and other game-specific files are copyrighted material and depending on the game, it may not be legal to download these files without permission from the copyright owner. Even if you own the PCB (printed circuit board, i.e. the game in hardware form), you might still need explicit permission from the manufacturer to legally play the game on MAME. For more information, check out the "Legal" section on the MAME website. There are some ROMs on MAME website which are authorized to be freely downloaded and used for non-commercial purposes.

After obtaining the ROM for the game you wish to play, place it in the "roms" folder in your MAME directory. ROMs usually come zipped, you should not unzip these files. There are two ways to run your game after this point. You can enter the following in the command prompt:

c:\mame>mame64.exe

This will bring a list of games found in your "roms" folder. You can also double-click the file "mame64.exe" in your MAME directory to get the same list.

The other way to run a game is to include the name of the ROM file of the game to the command, which will start the game directly. For instance, if you want to play the game "Hard Hat", you should enter the following command:

c:\mame>mame64.exe hardhat

Here, "hardhat" is the name of the ROM file. If the game does not start, this could be because of a number of reasons. Double check that the ROM file is in the "roms" directory, with the correct name and extension. It is important that the name of the zip file is exactly the same as what the program is expecting, otherwise MAME will not be able to start the game. Next, it could be that the game needs another file to run. For instance, Neo-Geo games will require what is known as a "Neo-Geo Bios" file to run. Finally, you might have an old version of the ROM file. As new versions of MAME come out, some games are updated and your ROM file should be the most recent version of the game as well. If you suspect this might be the case, try obtaining the ROM file from different sources.

Once you get the game running, you might want to re-define the controls for the game. To do this, press the TAB button while running the game.

From the menu, you can define the keys just for the game you are playing (Input (This Game) option) or for all the games (Input (General) option). Depending on the game, options such as difficulty, starting lives, bonus lives etc. may be changed from the "Dip Switches" section. You might also want to go to the "Video Options" section and try different video modes to see which one you like the best.

If you would like to use a joystick, you should add the "-joy" option to the command. For instance, to play the game "Hard Hat" with a joystick, enter the following command:

c:\mame>mame64.exe hardhat -joy

Similarly, if you would like to use mouse as a controller (for shooting games for instance), you should use the "-mouse" option.

If you want to keep your ROM files in a different folder (for instance, if you have multiple versions of MAME and would like all of them to use the same ROM folder), you should first ask MAME to create a config file by entering the following:

c:\mame>mame64.exe -cc

This will create a file named "mame.ini" in your MAME directory. Next, open this file with a text editor and change the value that corresponds to "rompath" with the folder you would like to use.

The last thing I will cover in this tutorial is saving and loading within MAME. This is a very useful feature of MAME, one which you don't get with real arcade machines. While playing a game, you can save your progress by pressing SHIFT+F7 and then choosing a position (i.e. a number from 1 to 9). Later (of course, when you are running the same game) you can go back to your saved position by pressing F7 followed by the number you chose when you saved the game. When you want to play a certain part of the game, like a fight with a final boss, this feature will save you the trouble of playing the whole game to get to that point.