mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
Merge pull request #1748 from zpl1025/master
[translated] 20140819 Build a Raspberry Pi Arcade Machine.md
This commit is contained in:
commit
24e73478bf
@ -1,136 +0,0 @@
|
|||||||
zpl1025
|
|
||||||
Build a Raspberry Pi Arcade Machine
|
|
||||||
================================================================================
|
|
||||||
**Relive the golden majesty of the 80s with a little help from a marvel of the current decade.**
|
|
||||||
|
|
||||||
### WHAT YOU’LL NEED ###
|
|
||||||
|
|
||||||
- Raspberry Pi w/4GB SD-CARD.
|
|
||||||
- HDMI LCD monitor.
|
|
||||||
- Games controller or…
|
|
||||||
- A JAMMA arcade cabinet.
|
|
||||||
- J-Pac or I-Pac.
|
|
||||||
|
|
||||||
The 1980s were memorable for many things; the end of the cold war, a carbonated drink called Quatro, the Korg Polysix synthesiser and the Commodore 64. But to a certain teenager, none of these were as potent, or as perhaps familiarly illicit, as the games arcade. Enveloped by cigarette smoke and a barrage of 8-bit sound effects, they were caverns you visited only on borrowed time: 50 pence and a portion of chips to see you through lunchtime while you honed your skills at Galaga, Rampage, Centipede, Asteroids, Ms Pacman, Phoenix, R-Rype, Donkey Kong, Rolling Thunder, Gauntlet, Street Fighter, Outrun, Defender… The list is endless.
|
|
||||||
|
|
||||||
These games, and the arcade machine form factor that held them, are just as compelling today as they were 30 years ago. And unlike the teenage version of yourself, you can now play many of them without needing a pocket full of change, finally giving you an edge over the rich kids and their endless ‘Continues’. It’s time to build your own Linux-based arcade machine and beat that old high score.
|
|
||||||
|
|
||||||
We’re going to cover all the steps required to turn a cheap shell of an arcade machine into a Linux-powered multi-platform retro games system. But that doesn’t mean you’ve got to build the whole system at the same scale. You could, for example, forgo the large, heavy and potentially carcinogenic hulk of the cabinet itself and stuff the controlling innards into an old games console or an even smaller case. Or you could just as easily forgo the diminutive Raspberry Pi and replace the brains of your system with a much more capable Linux machine. This might make an ideal platform for SteamOS, for example, and for playing some of its excellent modern arcade games.
|
|
||||||
|
|
||||||
Over the next few pages we’ll construct a Raspberry Pi-based arcade machine, but you should be able to see plenty of ideas for your own projects, even if they don’t look just like ours. And because we’re building it on the staggeringly powerful MAME, you’ll be able to get it running on almost anything.
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade3.png)
|
|
||||||
|
|
||||||
We did this project before the model B+ came out. It should all work exactly the same on the newer board, and you should be able to get by without a powered USB Hub (click for larger).
|
|
||||||
|
|
||||||
### Disclaimer ###
|
|
||||||
|
|
||||||
One again we’re messing with electrical components that could cause you a shock. Make sure you get any modifications you make checked by a qualified electrician. We don’t go into any details on how to obtain games, but there are legal sources such as old games releases and newer commercial titles based on the MAME emulator.
|
|
||||||
|
|
||||||
#### Step1: The Cabinet ####
|
|
||||||
|
|
||||||
The cabinet itself is the biggest challenge. We bought an old two-player Bubble Bobble machine from the early 90s from eBay. It cost £220 delivered in the back of an old estate car. The prices for cabinets like these can vary. We’ve seen many for less than £100. At the other end of the scale, people pay thousands for machines with original decals on the side.
|
|
||||||
|
|
||||||
There are two major considerations when it comes to buying a cabinet. The first is the size: These things are big and heavy. They take up a lot of space and it takes at least two people to move them around. If you’ve got the money, you can buy DIY cabinets or new smaller form-factors, such as cabinets that fit on tables. And cocktail cabinets can be easier to fit, too.
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade4.jpg)
|
|
||||||
|
|
||||||
Cabinets can be cheap, but they’re heavy. Don’t lift them on your own. Older ones may need some TLC, such as are-spray and some repair work(click for larger).
|
|
||||||
|
|
||||||
One of the best reasons for buying an original cabinet, apart from getting a much more authentic gaming experience, is being able to use the original controls. Many machines you can buy on eBay will be for two concurrent players, with two joysticks and a variety of buttons for each player, plus the player one and player two controls. For compatibility with the widest number of games, we’d recommend finding a machine with six buttons for each player, which is a common configuration. You might also want to look into a panel with more than two players, or one with space for other input controllers, such as an arcade trackball (for games like Marble Madness), or a spinner (Arkanoid). These can be added without too much difficulty later, as modern USB devices exist.
|
|
||||||
|
|
||||||
Controls are the second, and we’d say most important consideration, because it’s these that transfer your twitches and tweaks into game movement. What you need to consider for when buying a cabinet is something called JAMMA, an acronym for Japan Amusement Machinery Manufacturers. JAMMA is a standard in arcade machines that defines how the circuit board containing the game chips connects to the game controllers and the coin mechanism. It’s an interface conduit for all the cables coming from the buttons and the joysticks, for two players, bringing them into a standard edge connector. The JAMMA part is the size and layout of this connector, as it means the buttons and controls will be connected to the same functions on whichever board you install so that the arcade owner would only have to change the cabinet artwork to bring in new players.
|
|
||||||
|
|
||||||
But first, a word of warning: the JAMMA connector also carries the 12V power supply, usually from a power unit installed in most arcade machines. We disconnecting the power supply completely to avoid damaging anything with a wayward short-circuit or dropped screwdriver. We don’t use any of the power connectors in any further stage of the tutorial.
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade2.png)
|
|
||||||
|
|
||||||
#### Step 2: J-PAC ####
|
|
||||||
|
|
||||||
What’s brilliant is that you can buy a device that connects to the JAMMA connector inside your cabinet and a USB port on your computer, transforming all the buttons presses and keyboard movements into (configurable) keyboard commands that you can use from Linux to control any game you wish. This device is called the J-Pac ([www.ultimarc.com/jpac.html][1] – approximately £54).
|
|
||||||
|
|
||||||
Its best feature isn’t the connectivity; it’s the way it handles and converts the input signals, because it’s vastly superior to a standard USB joystick. Every input generates its own interrupt, and there’s no limit to the number of simultaneous buttons and directions you can press or hold down. This is vital for games like Street Fighter, because they rely on chords of buttons being pressed simultaneously and quickly, but it’s also essential when delivering the killing blow to cheating players who sulk and hold down all their own buttons. Many other controllers, especially those that create keyboard inputs, are restricted by their USB keyboard controllers to six inputs and a variety of Alt, Shift and Ctrl hacks. The J-Pac can also be connected to a tilt sensor and even some coin mechanisms, and it works in Linux without any pre-configuration.
|
|
||||||
|
|
||||||
Another option is a similar device called an I-Pac. It does the same thing as the J-Pac, only without the JAMMA connector. That means you can’t connect your JAMMA controls, but it does mean you can design your own controller layout and wire each control to the I-Pac yourself. This might be a little ambitious for a first project, but it’s a route that many arcade aficionados take, especially when they want to design a panel for four players, or one that incorporates many different kinds of controls. Our approach isn’t necessarily one we’d recommend, but we re-wired an old X-Arcade Tankstick control panel that suffered from input contention, replaced the joysticks and buttons with new units and connected it to a new JAMMA harness, which is an excellent way of buying all the cables you need plus the edge connector for a low price (£8).
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade5.jpg)
|
|
||||||
|
|
||||||
Our J-Pac in situ. The blue and red wires on the right connect to the extra 1- and 2-player buttons on our cabinet (click for larger).
|
|
||||||
|
|
||||||
Whether you choose an I-Pac or a J-Pac, all the keys generated by both devices are the default values for MAME. That means you won’t have to make any manual input changes when you start to run the emulator. Player 1, for example, creates cursor up, down, left and right as well as left Ctrl, left ALT, Space and left Shift for fire buttons 1–4. But the really useful feature, for us, is the two-button shortcuts. While holding down the player 1 button, you can generate the P key to pause the game by pulling down on the player 1 joystick, adjust the volume by pressing up and enter MAME’s own configuration menu by pushing right. These escape codes are cleverly engineered to not get in the way of playing games, as they’re only activated when holding down the Player 1 button, and they enable you to do almost anything you need to from within a running game. You can completely reconfigure MAME, for example, using its own menus, and change input assignments and sensitivity while playing the game itself.
|
|
||||||
|
|
||||||
Finally, holding down Player 1 and then pressing Player 2 will quit MAME, which is useful if you’re using a launch menu or MAME manager, as these manage launching games automatically, and let you get on with playing another game as quickly as possible.
|
|
||||||
|
|
||||||
We took a rather cowardly route with the screen, removing the original, bulky and broken CRT that came with the cabinet and replacing it with a low-cost LCD monitor. This approach has many advantages. First, the screen has HDMI, so it will interface with a Raspberry Pi or a modern graphics card without any difficulty. Second, you don’t have to configure the low-frequency update modes required to drive an arcade machine’s screen, nor do you need the specific graphics hardware that drives it. And third, this is the safest option because an arcade machine’s screen is often unprotected from the rear of a case, leaving very high voltages inches away from your hands. That’s not to say you shouldn’t use a CRT if that’s the experience you’re after – it’s the most authentic way to get the gaming experience you’re after, but we’ve fined-tuned the CRT emulation enough in software that we’re happy with the output, and we’re definitely happier not to be using an ageing CRT.
|
|
||||||
|
|
||||||
You might also want to look into using an older LCD with a 4:3 aspect ratio, rather than the widescreen modern options, because 4:3 is more practical for playing both vertical and horizontal games. A vertical shooter such as Raiden, for example, will have black bars on either side of the gaming area if you use a widescreen monitor. Those black bars can be used to display the game instructions, or you could rotate the screen 90 degrees so that every pixel is used, but this is impractical unless you’re only going to play vertical games or have easy access to a rotating mount.
|
|
||||||
|
|
||||||
Mounting a screen is also important. If you’ve removed a CRT, there’s nowhere for an LCD to go. Our solution was to buy some MDF cut to fit the space where the CRT was. This was then screwed into position and we fitted a cheap VESA mounting plate into the centre of the new MDF. VESA mounts can be used by the vast majority of screens, big and small. Finally, because our cabinet was fronted with smoked glass, we had to be sure both the brightness and contrast were set high enough.
|
|
||||||
|
|
||||||
### Step 3: Installation ###
|
|
||||||
|
|
||||||
With the large hardware choices now made, and presumably the cabinet close to where you finally want to install it, putting the physical pieces together isn’t that difficult. We safely split the power input from the rear of the cabinet and wired a multiple socket into the space at the back. We did this to the cable after it connects to the power switch.
|
|
||||||
|
|
||||||
Nearly all arcade cabinets have a power switch on the top-right surface, but there’s usually plenty of cable to splice into this at a lower point in the cabinet, and it meant we could use normal power connectors for our equipment. Our cabinet has a fluorescent tube, used to backlight the top marquee on the machine, connected directly to the power, and we were able to keep this connected by attaching a regular plug. When you turn the power on from the cabinet switch, power flows to the components inside the case – your Raspberry Pi and screen will come on, and all will be well with the world.
|
|
||||||
|
|
||||||
The J-Pac slides straight into the JAMMA interface, but you may also have to do a little manual wiring. The JAMMA standard only supports up to three buttons for each player (although many unofficially support four), while the J-Pac can handle up to six buttons. To get those extra buttons connected, you need to connect one side of the button’s switch to GND fed from the J-Pac with the other side of the switch going into one of the screw-mounted inputs in the side of the J-Pac. These are labelled 1SW4, 1SW5, 1SW6, 2SW4, 2SW5 and 2SW6. The J-Pac also includes passthrough connections for audio, but we’ve found this to be incredibly noisy. Instead, we wired the speaker in our cabinet to an old SoundBlaster amplifier and connected this to the audio outputs on the Raspberry Pi. You don’t want audio to be pristine, but you do want it to be loud enough.
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade6.jpg)
|
|
||||||
|
|
||||||
Our Raspberry Pi is now connected to the J-Pac on the left and both the screen and the USB hub (click for larger).
|
|
||||||
|
|
||||||
The J-Pac or I-Pac then connects to your PC or Raspberry Pi using a PS2-to-USB cable, which should also be used to connect to a PS2 port on your PC directly. There is an additional option to use an old PS2 connector, if your PC is old enough to have one, but we found in testing that the USB performance is identical. This won’t apply to the PS2-less Raspberry Pi, of course, and don’t forget that the Pi will also need powering. We always recommend doing so from a compatible powered hub, as a lack of power is the most common source of Raspberry Pi errors. You’ll also need to get networking to your Raspberry Pi, either through the Ethernet port (perhaps using a powerline adaptor hidden in the cabinet), or by using a wireless USB device. Networking is essential because it enables you to reconfigure your PI while it’s tucked away within the cabinet, and it also enables you to change settings and perform administration tasks without having to connect a keyboard or mouse.
|
|
||||||
|
|
||||||
> ### Coin Mechanism ###
|
|
||||||
|
|
||||||
> In the emulation community, getting your coin mechanism to work with your emulator was often considered a step too close to commercial production. It meant you could potential charge people to use your machine. Not only would this be wrong, but considering the provenance of many of the games you run on your own arcade machine, it could also be illegal. And it’s definitely against the spirit of emulation. However, we and many other devotees thinking that a working coin mechanism is another step closer to the realism of an arcade machine, and is worth the effort in recreating the nostalgia of an old arcade. There’s nothing like dropping a 10p piece into the coin tray and to hear the sound of the credits being added to the machine.
|
|
||||||
|
|
||||||
> It’s not actually that difficult. It depends on the coin mechanism in your arcade machine and how it sends a signal to say how many credits had been inserted. Most coin mechanisms come in two parts. The large part is the coin acceptor/validator. This is the physical side of the process that detects whether a coin is authentic, and determines its value. It does this with the help of a credit/logic board, usually attached via a ribbon cable and featuring lots of DIP switches. These switches are used to change which coins are accepted and how many credits they generate. It’s then usually as simple as finding the output switch, which is triggered with a credit, and connecting this to the coin input on your JAMMA connector, or directly onto the J-Pac. Our coin mechanism is a Mars MS111, common in the UK in the early 90s, and there’s plenty of information online about what each of the DIP switches do, as well as how to programme the controller for newer coins. We were also able to wire the 12V connector from the mechanism to a small light for behind the coin entry slot.
|
|
||||||
|
|
||||||
#### Step 4: Software ####
|
|
||||||
|
|
||||||
MAME is the only viable emulator for a project of this scale, and it now supports many thousands of different games running on countless different platforms, from the first arcade machines through to some more recent ones. It’s a project that has also spawned MESS, the multi-emulator super system, which targets platforms such as home computers and consoles from the 80s and 90s.
|
|
||||||
|
|
||||||
Configuring MAME could take a six-page article in itself. It’s a complex, sprawling, magnificent piece of software that emulates so many CPUs, so many sound devices, chips, controllers with so many options, that like MythTV, you never really stop configuring it.
|
|
||||||
|
|
||||||
But there’s an easier option, and one that’s purpose-built for the Raspberry Pi. It’s called PiMAME. This is both a distribution download and a script you can run on top of Raspbian, the Pi’s default distribution. Not only does it install MAME on your Raspberry Pi (which is useful because it’s not part of any of the default repositories), it also installs a selection of other emulators along with front-ends to manage them. MAME, for example, is a command-line utility with dozens of options. But PiMAME has another clever trick up its sleeve – it installs a simple web server that enables you to install new games through a browser connected to your network. This is a great advantage, because getting games into the correct folders is one of the trials of dealing with MAME, and it also enables you to make best use of whatever storage you’ve got connected to your Pi. Plus, PiMAME will update itself from the same script you use to install it, so keeping on top of updates couldn’t be easier. This could be especially useful at the moment, as at the time of writing the project was on the cusp of a major upgrade in the form of the 0.8 release. We found it slightly unstable in early March, but we’re sure everything will be sorted by the time you read this.
|
|
||||||
|
|
||||||
The best way to install PiMAME is to install Raspbian first. You can do this either through NOOBS, using a graphical tool from your desktop, or by using the dd command to copy the contents of the Raspbian image directly onto your SD card. As we mentioned in last month’s BrewPi tutorial, this process has been documented many times before, so we won’t waste the space here. Just install NOOBS if you want the easy option, following the instructions on the Raspberry Pi site. With Raspbian installed and running, make sure you use the configuration tool to free the space on your SD card, and that the system is up to date (sudo apt-get update; sudo apt-get upgrade). You then need to make sure you’ve got the git package already installed. Any recent version of Raspbian will have installed git already, but you can check by typing sudo apt-get install git just to check.
|
|
||||||
|
|
||||||
You then have to type the following command to clone the PiMAME installer from the project’s GitHub repository:
|
|
||||||
|
|
||||||
git clone https://github.com/ssilverm/pimame_installer
|
|
||||||
|
|
||||||
After that, you should get the following feedback if the command works:
|
|
||||||
|
|
||||||
Cloning into ‘pimame_installer’...
|
|
||||||
remote: Reusing existing pack: 2306, done.
|
|
||||||
remote: Total 2306 (delta 0), reused 0 (delta 0)
|
|
||||||
Receiving objects: 100% (2306/2306), 4.61 MiB | 11 KiB/s, done.
|
|
||||||
Resolving deltas: 100% (823/823), done.
|
|
||||||
|
|
||||||
This command will create a new folder called ‘pimame_installer’, and the next step is to switch into this and run the script it contains:
|
|
||||||
|
|
||||||
cd pimame_installer/
|
|
||||||
sudo ./install.sh
|
|
||||||
|
|
||||||
This command installs and configures a lot of software. The length of time it takes will depend on your internet connection, as a lot of extra packages are downloaded. Our humble Pi with a 15Mb internet connection took around 45 minutes to complete the script, after which you’re invited to restart the machine. You can do this safely by typing sudo shutdown -r now, as this command will automatically handle any remaining write operations to the SD card.
|
|
||||||
|
|
||||||
And that’s all there is to the installation. After rebooting your Pi, you will be automatically logged in and the PiMAME launch menu will appear. It’s a great-looking interface in version 0.8, with photos of each of the platforms supported, plus small red icons to indicate how many games you’ve got installed.This should now be navigable through your controller. If you want to make sure the controller is correctly detected, use SSH to connect to your Pi and check for the existence of **/dev/input/by-id/usb-Ultimarc_I-PAC_Ultimarc_I-PAC-event-kbd**.
|
|
||||||
|
|
||||||
The default keyboard controls will enable you to select what kind of emulator you want to run on your arcade machine. The option we’re most interested in is the first, labelled ‘AdvMAME’, but you might also be surprised to see another MAME on offer, MAME4ALL. MAME4ALL is built specifically for the Raspberry Pi, and takes an old version of the MAME source code so that the performance of the ROMS that it does support is optimal. This makes a lot of sense, because there’s no way your Pi is going to be able to play anything too demanding, so there’s no reason to belabour the emulator with unneeded compatibility. All that’s left to do now is get some games onto your system (see the boxout below), and have fun!
|
|
||||||
|
|
||||||
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade1.png)
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://www.linuxvoice.com/arcade-machine/
|
|
||||||
|
|
||||||
作者:[Ben Everard][a]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:http://www.linuxvoice.com/author/ben_everard/
|
|
||||||
[1]:http://www.ultimarc.com/jpac.html
|
|
@ -1,3 +1,4 @@
|
|||||||
|
zpl1025
|
||||||
How to use xargs command in Linux
|
How to use xargs command in Linux
|
||||||
================================================================================
|
================================================================================
|
||||||
Have you ever been in the situation where you are running the same command over and over again for multiple files? If so, you know how tedious and inefficient this can feel. The good news is that there is an easier way, made possible through the xargs command in Unix-based operating systems. With this command you can process multiple files efficiently, saving you time and energy. In this tutorial, you will learn how to execute a command or script for multiple files at once, avoiding the daunting task of processing numerous log files or data files individually.
|
Have you ever been in the situation where you are running the same command over and over again for multiple files? If so, you know how tedious and inefficient this can feel. The good news is that there is an easier way, made possible through the xargs command in Unix-based operating systems. With this command you can process multiple files efficiently, saving you time and energy. In this tutorial, you will learn how to execute a command or script for multiple files at once, avoiding the daunting task of processing numerous log files or data files individually.
|
||||||
@ -113,4 +114,4 @@ via: http://xmodulo.com/xargs-command-linux.html
|
|||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
[a]:http://xmodulo.com/author/joshua
|
[a]:http://xmodulo.com/author/joshua
|
||||||
|
135
translated/tech/20140819 Build a Raspberry Pi Arcade Machine.md
Normal file
135
translated/tech/20140819 Build a Raspberry Pi Arcade Machine.md
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
自制一台树莓派街机
|
||||||
|
================================================================================
|
||||||
|
**利用当代神奇设备来重温80年代的黄金威严。**
|
||||||
|
|
||||||
|
### 你需要以下硬件 ###
|
||||||
|
|
||||||
|
- 一台树莓派以及一张4GBSD卡
|
||||||
|
- 一台支持HDMI的LCD显示屏
|
||||||
|
- 游戏手柄或者...
|
||||||
|
- 一个JAMMA街机游戏机外壳机箱
|
||||||
|
- J-Pac或者I-Pac
|
||||||
|
|
||||||
|
80年代有太多难忘的记忆;冷战结束,Quatro碳酸饮料,Korg Polysix合成器,以及Commodore 64家用电脑。但对于某些年轻人来说,这些都没有街机游戏机那样有说服力,或那种甜蜜的叛逆。笼罩着烟味和此起彼伏的8比特音效,它们就是在挤出来的时间里去探索的洞穴:50分钱和一份代币能让你消耗整个午餐时间,在这些游戏上磨练着你的技能:小蜜蜂,城市大金刚,蜈蚣,行星射击,吃豆小姐,火凤凰,R-Rype,大金刚,雷霆计划,铁手套,街头霸王,超越赛车,防卫者争战...这个列表太长了。
|
||||||
|
|
||||||
|
这些游戏,以及玩这些游戏的街机机器,仍然像30年前那样有吸引力。不像年轻时候那样,现在可以不用装一兜零钱就能玩了,最终让你超越那些有钱的孩子以及他们无休止的‘继续游戏’。所以是时候打造一个你自己的基于Linux的街机游戏机了,然后挑战一下过去的最高分。
|
||||||
|
|
||||||
|
我们将会覆盖所有的步骤,来将一个便宜的街机游戏机器外壳变成一台Linux驱动的多平台复古游戏系统。但是这并不意味着你就一定要搭建一个同样的系统。比如说,你可以放弃那个又大又重还有潜在致癌性外壳的箱子本身,而是将内部控制核心装进一个旧游戏主机或同等大小的盒子里。或者说,你也可以简单地放弃小巧的树莓派,而将系统的大脑换成一台更强劲的Linux主机。举个例子,它可以作为运行SteamOS的一个理想平台,用来玩那些更优秀的现代街机游戏。
|
||||||
|
|
||||||
|
在之后的几个页面里,我们将搭建一台基于树莓派的街机游戏机,你应该也能从其中发现很多点子应用到你自己的项目上,即使它们和我们这个项目不太一样。然后因为我们是用无比强大的MAME来做这件事情,你几乎可以让它在任意平台上运行。
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade3.png)
|
||||||
|
|
||||||
|
我们在B+型号出来以前完成的这个项目。它应该也可以同样工作在更新的主板上,你应该不用一个带电源的USB Hub也可以(点击看大图)。
|
||||||
|
|
||||||
|
### 声明 ###
|
||||||
|
|
||||||
|
强调一下,我们捣腾的电子器件可能会让你受到电击。请确保你做的任何改动都是有资质的电子工程师帮你检查过的。我们也不会深入讨论如何获取游戏,但是有很多合法的资源,例如基于MAME模拟器的老游戏,以及较新的商业游戏。
|
||||||
|
|
||||||
|
#### 第一步:街机机柜 ####
|
||||||
|
|
||||||
|
街机机柜本身就是最大的挑战。我们在eBay上淘了个二手的90年代初的双人泡泡龙游戏机。然后花了£220装在一台旅行车后面送过来。类似这种机柜的价格并不确定。我们看到过很多在£100以内的。而另一方面,还有很多人愿意花数千块钱去买原版侧面贴纸完整的机器。
|
||||||
|
|
||||||
|
决定买一个街机机柜,主要有两个考虑。第一个是它的体积:这东西又大又重。又占地方,而且需要至少两个人才能搬动。如果你不缺钱的话,还可以买DIY机柜或者全新的小一点的,例如适合摆在桌子上的那种。然后,酒柜也能很合适。
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade4.jpg)
|
||||||
|
|
||||||
|
这种机柜可能很便宜,但是他们都很重。不要一个人去搬。一些更古老的机器可能还会需要一点小关怀,例如重新喷个漆以及一些修理工作(点击看大图)。
|
||||||
|
|
||||||
|
除了获得更加真实的游戏体验以外,购买原版的街机机柜的一个绝佳理由是可以使用原版的控制器。从eBay上买到的大多数机器都支持两个人同时玩,有两个摇杆以及每个玩家各自的一些按钮,再加上玩家一和玩家二的选择按钮。为了兼容更多游戏,我们建议您找一台每个玩家都有6个按键,这个是通用配置。也许你还想看看支持超过两位玩家的控制台,或者有空间放其他游戏控制器的,比如说街机轨迹球(类似疯狂弹珠这种游戏需要的),或者一个旋钮(打砖块)。这些待会都可以轻松装上去,因为有现成的现代USB设备。
|
||||||
|
|
||||||
|
控制器是第二考虑的,而且我们认为是最重要的,因为要通过它把你的摇动和拍打转变成游戏里的动作。当你准备买一个机柜时需要考虑一种叫JAMMA的东西,它是日本娱乐机械制造商协会(Japan Amusement Machinery Manufacturers Association)的缩写。JAMMA是街机游戏机里的行业标准,定义了包含游戏芯片的电路板和游戏控制器的连接方式,以及投币机制。它是一个连接两个玩家的摇杆和按钮的所有线缆的接口电路,把它们统一到一个标准的连接头。JAMMA就是这个连接头的大小以及引脚定义,这就意味着不管你安装的主板是什么,按钮和控制器都将会连接到相同功能接口,所以街机的主人只需要再更换下机柜上的外观图片,就可以招揽新玩家了。
|
||||||
|
|
||||||
|
但是首先,提醒一下:JAMMA连接头上带有12V电压供电,通常由大多数街机里都有的电源模块供给。为了避免意外短路或是不小心掉个螺丝刀什么的造成损坏,我们完全切断了这个供电。在本教程后面的任何阶段,我们也不会用到这个连接头上的任何电源脚。
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade2.png)
|
||||||
|
|
||||||
|
#### 第二步:J-PAC ####
|
||||||
|
|
||||||
|
有一点非常方便,你可以买到这样一种设备,连接街机机柜里的JAMMA接头和电脑的USB端口,将机柜上的摇杆和按键动作都转换成(可配置的)键盘命令,它们可以在Linux里用来控制任何想玩的游戏。这个设备就叫J-Pac([www.ultimarc.com/jpac.html][1] – 大概£54)。
|
||||||
|
|
||||||
|
它最大的特点不是它的连接性;而是它处理和转换输入信号的方式,因为它比标准的USB手柄强太多太多了。每一个输入都有自己独立的中断,而且没有限制同时按下或按住的按钮或摇杆方向的数量。这对于类似街头霸王的游戏来说非常关键,因为他们依赖于同时迅速按下的组合键,而且用来对那些发飙后按下自己所有按键的不良对手发出致命一击时也必不可少。许多其他控制器,特别是那些生成键盘输入的,受到他们所采用的USB控制器的同时六个输入的限制,以及一堆的Alt,Shift和Ctrl键的特殊处理的限制。J-Pac还可以接入倾角传感器,甚至某些投币装置,不用预先配置就可以在Linux下工作了。
|
||||||
|
|
||||||
|
另外的选择是一个类似的叫I-Pac的设备。它做了和J-Pac相同的事情,只不过不支持JAMMA接头。这意味着你不能把JAMMA控制器接上去,但同时也就是说你可以设计你自己的控制器布局,再把每个控制接到I-Pac上去。这对第一个项目来说也许有点小难,但是这却是许多街机迷们选择的方式,特别是他们想设计一个支持四个玩家的控制板的时候,或者是一个整合许多不同类型控制的面板的时候。我们采用的方式并不是我们推荐必须要做的,我们改造了一个输入有问题的二手X-Arcade Tankstick控制面板,换上了新的摇杆和按钮,再接到新的JAMMA接口,这样有一个非常好的地方就是可以用便宜的价格(£8)买到所有用到的线材包括电路板边缘插头。
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade5.jpg)
|
||||||
|
|
||||||
|
我们的已经装到机柜上的J-Pac。右边的蓝色和红色导线接到我们的机柜上额外的1号和2号玩家按钮(点击看大图)。
|
||||||
|
|
||||||
|
不管你选择的是I-Pac或是J-Pac,它们产生的按键都是MAME的默认值。也就是说运行模拟器之后不需要手动调整输入。例如玩家1,会默认将键盘方向键映射成上下左右,以及将左边的Ctrl,左边的ALT,空格和左边的Shift键映射到按钮1-4。但是真正实用的功能是,对于我们来说,是双键快捷方式。当按下并按住玩家1按钮后,就可以通过把玩家1的摇杆拉到下的位置发出用来暂停游戏的P按键,推到上的位置调整音量,以及推到右的位置来进入MAME自己的设置界面。这些特殊组合键设计的很巧妙,不会对正常玩游戏带来任何干扰,因为他们只有在按住玩家1按钮后才会生效,然后可以让你正在运行游戏的时候也能做任何需要的事情。例如,你可以完全地重新配置MAME,使用它自己的菜单,在玩游戏的时候改变输入绑定和灵敏度。
|
||||||
|
|
||||||
|
最后,按住玩家1按钮然后按下玩家2按钮就可以退出MAME,如果你使用了启动菜单或MAME管理器的话就很有用了,因为他们会自动启动游戏,然后你就可以用最快的速度开始玩另一个游戏了。
|
||||||
|
|
||||||
|
对于显示屏我们采取了比较保守的方式,拿掉了街机原装的笨重的而且已经坏掉的CRT,换成一个低成本的LCD显示器。这样做有很多好处。首先,这个显示器有HDMI接口,这样他就可以轻易地直接连接到树莓派或是现代的显卡上。第二,你也不用去设定驱动街机屏幕所需要的低频率刷新模式,也不需要驱动它的专用图形硬件。第三,这也是最安全的方式,因为街机屏幕往往在机身背后没有保护措施,让很高的电压离你的手只有几英寸的距离。也不是说你完全不能用CRT,如果那就是你追求的体验的话 – 这也是获得所追求的游戏体验的最真实的方式,但是我们在软件里充分细调了CRT模拟部分,我们对输出已经很满意了,而且不需要用那个古老的CRT更是让我们高兴。
|
||||||
|
|
||||||
|
你也许还需要考虑用一个老式的4:3长宽比的LCD,而不是那种宽屏的现代产品,因为4:3模式用来玩竖屏或横屏的游戏更实用。比如说玩竖屏的射击游戏,例如雷电,如果使用宽屏显示器的话,会在屏幕两边都有一个黑条。这些黑条一般会用来显示一些游戏指引,或者你也可以把屏幕翻转90度,这样就可以用上每个像素了,但这却不实用,除非你只玩竖屏游戏或者有一个容易操作的旋转支座。
|
||||||
|
|
||||||
|
装载显示屏也很重要。如果你拿掉了CRT的话,没有现成的地方安装LCD。我们的方式是买了一些中密度纤维板(MDF)并切割成适合原来摆放CRT的地方。固定以好,我们把一个便宜的VESA支座放在中间。VESA底座可以用来挂载大多数屏幕,大的或小的。最后,因为我们的机柜前面有烟玻璃,我们必须保证亮度和对比度都设置的足够高。
|
||||||
|
|
||||||
|
### 第三步:装配 ###
|
||||||
|
|
||||||
|
现在几个硬件大件都选好了,而且也基本上确定了最终街机机柜要摆放的地方,把这几个配件装到一起并没有太大难度。我们安全地把机柜后面的电源输入部分拆开,然后在背后的空间接了一个符合插座。接在了电源开关之后的电线上。
|
||||||
|
|
||||||
|
几乎所有的街机机柜右上角都有个电源开关,但通常在机柜靠下一点的地方有大量的导线铰接在它上面,也就是说我们的设备可以使用普通的电源连接头。我们的机柜上还有一个荧光管,用做机器上边灯罩的背光,之前是直接连接到电源上的,我们可以用一个普通插头让它保持和电源连接。当你打开机柜上的电源开关的时候,电流会流入机柜里的各个部件 - 你的树莓派和显示屏都会开机,所有一切就都准备好了。
|
||||||
|
|
||||||
|
J-Pac模块直接插到JAMMA接口上,但你可能还需要一点手动调整。标准的JAMMA只支持每个玩家最多三个按键(尽管许多非正式的支持四个),而J-Pac可以支持六个。为了连接额外的按钮,你需要把按钮开关的一端接到J-Pac的GND上,另一端接到J-Pac板边有螺丝固定的输入上。它们被标记成1SW4,1SW5,1SW6,2SW4,2SW5和2SW6。J-Pac也有声音的直通连接,但是我们发现杂音太多没法用。改成把机柜上的喇叭连接到一个二手的SoundBlaster功放上,再接到树莓派的音频输出端口。声音不一定要纯正,但音量一定要足够大。
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade6.jpg)
|
||||||
|
|
||||||
|
我们的树莓派已经接到J-Pac左边,也已经连接了显示屏和USB hub(点击看大图)。
|
||||||
|
|
||||||
|
然后把J-Pac或I-Pac模块通过PS2转USB连接线接到你的PC或树莓派,也可以直接接到PC的PS2接口。要用旧的PS2接头的话额外还有个要求,你的电脑得足够古老还有这个,但是我们测试发现用USB性能是一样的。当然,这个不能用于不带PS2的树莓派,而且别忘了树莓派也需要供电。我们一般建议使用一个带电源的USB hub,因为没有供电是树莓派不工作最常见的错误。你还需要保证树莓派的网络正常,要么通过以太网(也许使用一个藏到机柜里的电力线适配器),或者通过无线USB设备。网络很关键是因为在树莓派被藏到机柜里后你还可以重新配置它,不用接键盘或鼠标就可以让你调整设置以及执行管理任务。
|
||||||
|
|
||||||
|
> ### 投币装置 ###
|
||||||
|
|
||||||
|
> 在街机模拟社区里,让投币装置工作在模拟器上工作就会和商业产品太接近了。这就意味着你有潜在的可能对使用你机器的人收取费用。这不仅仅只是不正当,考虑到运行在你自己街机上的那些游戏的来源,这将会是非法的。这很显然违背了模拟的精神。不过,我们和其他热爱者觉得一个能工作的投币装置更进一步地靠近了街机的真实,而且值得付出努力来营造对那个过去街机的怀念。丢个10便士硬币到投币口然后再听到机器发出增加点数的声音,没有什么比得上。
|
||||||
|
|
||||||
|
> 实际上难度也不大。取决于你街机上的投币装置,以及它如何发信号通知投了几个币。大多数投币装置分为两个部分。较大的一部分是硬币接收和验证装置。这是投币过程的物理部分,用于检测硬币是否真实以及确定它的价值。这是通过一个游戏点数逻辑电路板来实现的,通常用一个排线连接,上边还带有很多DIP开关。这些开关用来决定接受哪种硬币,以及一个硬币能产生多少点数。然后就是简单地找到输出开关,每个点数都会触发它一次,然后把它接到JAMMA连接头的投币输入上,或者直接接到J-Pac。我们的投币装置型号是Mars MS111,在90年代早期的英国很常见,网上有大量关于每个DIP开关作用的信息,也有如何重新编程控制器来接受新硬币的方法。我们还能在这个装置的12V上接个小灯用来照亮投币孔。
|
||||||
|
|
||||||
|
#### 第四步:软件 ####
|
||||||
|
|
||||||
|
MAME是这种规模项目唯一可行的模拟器,它如今支持运行在数不清的不同平台上的各种各样的游戏,从第一代街机到一些最近的机器。从这个项目中还孕育出了MESS,一个多模拟器的超级系统,针对的平台是80到90年代的家庭电脑以及电视游戏机。
|
||||||
|
|
||||||
|
如何配置MAME本身都可以写上六页的文章了。它是一个复杂的,无序的,伟大的软件程序,模拟了如此之多的CPU,声卡,芯片,控制器以及那么多的选项,就像MythTV,你都永远不能真正停止配置它。
|
||||||
|
|
||||||
|
但是也有个相对省事的方式,一个特别为树莓派构建的版本。它叫PiMAME。它是一个可下载的发布版和脚本,基于Raspbian,这是树莓派的默认发布版。它不仅仅会把MAME装到树莓派上(这很有用因为没有哪个默认仓库里有这个),还会安装其他一些精选出来的模拟器,并通过一个前端来管理他们。MAME,举个例子,是一个有数十个参数的命令行应用。但是PiMAME还有一个妙招 - 它安装了一个简单的网页服务器,可以在连接上网络后让你通过浏览器来安装新游戏。这是一个很好的优点,因为把游戏文件放到正确的目录下是使用MAME的困难之一,这还能让你连接到树莓派的存储设备得到最优使用。还有,PiMAME会通过用来安装它的脚本更新自己,所以保持最新版本就太简单了。目前来说这个非常有用,因为在编写这个项目的时候,正好在0.8版这样一个重大更新发布的时间点上。我们在三月份早期时发现有一些轻微的不稳定,但是我们确定在你读到这篇文章的时候一切都会解决。
|
||||||
|
|
||||||
|
安装PiMAME最好的方式就是先装Raspbian。你可以通过NOOBS安装,使用电脑上的图形工具,或者通过dd命令把Raspbian的内容直接写入到你的SD卡中。就像我们上个月的BrewPi教程里曾提到的,这个过程在之前已经被记录过很多次,所以就不再浪费口水了。想简单点就装一下NOOBS,参照树莓派网站上的指引。在装好Raspbian并跑起来以后,请确保使用配置工具来释放SD卡上的空间,以及确保系统已经更新到最新(`sudo apt-get update; sudo apt-get upgrade`)。然后再确保已经安装好了git工具包。当前任意Raspbian版本都会自带git,不过你仍然可以通过命令`sudo apt-get install git`检查一下。
|
||||||
|
|
||||||
|
然后再在终端里输入下面的命令把PiMAME安装器从项目的GitHub仓库克隆到本地:
|
||||||
|
|
||||||
|
git clone https://github.com/ssilverm/pimame_installer
|
||||||
|
|
||||||
|
之后,如果命令工作正常的话你应该能看到如下的反馈输出:
|
||||||
|
|
||||||
|
Cloning into ‘pimame_installer’...
|
||||||
|
remote: Reusing existing pack: 2306, done.
|
||||||
|
remote: Total 2306 (delta 0), reused 0 (delta 0)
|
||||||
|
Receiving objects: 100% (2306/2306), 4.61 MiB | 11 KiB/s, done.
|
||||||
|
Resolving deltas: 100% (823/823), done.
|
||||||
|
|
||||||
|
这个命令会创建一个叫‘pimame_installer’的新目录,然后下一步就是进入这个目录再执行它里面的脚本:
|
||||||
|
|
||||||
|
cd pimame_installer/
|
||||||
|
sudo ./install.sh
|
||||||
|
|
||||||
|
这个命令会安装和配置很多软件。所需的时间长短也取决于你的因特网速度,因为需要下载大量的包。我们那个简陋的树莓派加15Mb因特网连接用了差不多45分钟来执行完这个脚本,在这之后你会收到重启机器的提示。你现在可以安全的通过输入`sudo shutdown -r`来重启了,因为这个命令会自动处理剩下的SD卡写入操作。
|
||||||
|
|
||||||
|
这就是安装的全部事情了。在重启树莓派后,就会自动登录,然后会出现PiMAME启动菜单。在0.8版本里这是个非常漂亮的界面,有每个支持平台的图片,还有红色图标提示已经安装了多少个游戏。现在应该可以用控制器来操作了。如果需要检查控制器是否正确连接,可以用SSH连接到树莓派然后检查一下文件**/dev/input/by-id/usb-Ultimarc_I-PAC_Ultimarc_I-PAC-event-kbd**是否存在。
|
||||||
|
|
||||||
|
默认的按键配置就可以让你选择要在你的街机上运行哪个模拟器。我们最感兴趣的就是第一个,名字叫‘AdvMAME’,不过你也许会很惊讶看到还有一个MAME可选的,MAME4ALL。MAME4ALL是特别为树莓派构建的,使用了旧版的MAME源代码,所以它所支持的ROMS的性能也是最佳的。这是很合理的,因为你的树莓派不可能玩那些要求很高的游戏,所以没有理由苛求模拟器的没必要的兼容性。现在剩下的事情就是找些游戏装到你的系统里(参考下面的方法),然后尽情享受吧!
|
||||||
|
|
||||||
|
![](http://www.linuxvoice.com/wp-content/uploads/2014/08/picade1.png)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://www.linuxvoice.com/arcade-machine/
|
||||||
|
|
||||||
|
作者:[Ben Everard][a]
|
||||||
|
译者:[zpl1025](https://github.com/zpl1025)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:http://www.linuxvoice.com/author/ben_everard/
|
||||||
|
[1]:http://www.ultimarc.com/jpac.html
|
Loading…
Reference in New Issue
Block a user