UpFRONT
#include <math.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
int main(void)
{
unsigned short int wave[44100]; /* our wavetable */
int c; /* a counter */
int out; /* audio out */
/* open /dev/dsp for write only */
out = open("/dev/dsp",O_WRONLY);
/* now we use ioctl to set audio quality */
c=16; /* 16 bits */
ioctl(out,SOUND_PCM_WRITE_BITS,&c);
c=1; /* 1 channel */
ioctl(out,SOUND_PCM_WRITE_CHANNELS,&c);
c=44100; /* 44.1KHz */
ioctl(out,SOUND_PCM_WRITE_RATE,&c);
/* this generates the wavetable of our sines
* it's standard trig, so play around with
* whatever crazy equations you want to hear!
*/
for (c=0; c<44100; c++) {
wave[c] =8000*sin(220*2*M_PI*(c+13)/44100);
wave[c]+=7000*sin(277*2*M_PI*(c+29)/44100);
wave[c]+=6000*sin(330*2*M_PI*(c+41)/44100);
wave[c]+=5000*sin(440*2*M_PI*(c+67)/44100);
}
/* now we write the wavetable to /dev/dsp
* as though writing to a simple file
* we'll loop for 5 seconds of sheer joy
*/
for (c=0; c<5; c++)
write(out, wave, sizeof(wave));
close(out); /* close /dev/dsp ! */
return 0; /* satisfy gcc */
}
This listing is available by anonymous download in the file ftp.linuxjournal.com/pub/lj/listings/issue71/3836.tgz.
Imagine if computers had a use: if you could walk in, turn one on, and use it for something. Case in point: suppose that on your wall lived an enormous, flat panel monitor, and controlling it, a Linux box—very fast, faster even than normal. What to do? Revel in high culture! What's that, you say? Play games, that is, bigger and better than you've ever seen them before. What games? Antique games. Vintage games. Aged rarities. Far more than just games, these are cultural entities, which so many of us grew up with, and which once resided in arcades and pizza parlors when games cost a quarter to play. As is well-known, aging does a lot for software. Unlike people, who grow old and die, computer programs gain in energy with age, and when double-compiled and then stored in silicon casks for several years, the bits reduce and compress, leaving stronger elemental semiconductor properties, while taking out the fire. A fine vintage game is more fun than vi!
Oh, but arcade machines were often 6502-based, or even 68000-based (and a host of others); at any rate, not x86. How can we possibly run these programs, and where are we going to get the code? Fortunately, in 1997 a very cool Italian hacker by the name of Nicola Salmoria began a project to write an emulator for old hardware in order to preserve classic games so that they would never be forgotten, but enjoyed and shared around the world. Within a short time, MAME had grown to support over a thousand games, with 1951 at last count.
MAME can be played in X or console mode, and on several different platforms (including DOS, Macintosh and Amiga). You need to have a fairly fast machine in order to get the best performance on complicated games, but the farther back in time you go, the less processor-intensive the games are. If you have anything halfway decent in terms of hardware, you can enjoy the finer elements of computer culture.
The one problem is that MAME is only an emulator; it doesn't include the ROM images. You have to get ROMs, but apparently it is quite illegal (a felony) to duplicate these things. Hence, instead of openly distributing these images, we have to make secret hunts over the Web to find them. Fortunately, it's very easy to find huge ROM repositories, even though Dave's Classics, which used to be the most complete location, was coerced into taking the ROMs off-line a couple of years ago. Major gaming companies are upset with ROMs, probably since they see emulation ultimately encompassing the console games they currently make (or maybe they realize the older games are superior in game play anyway). Either way, it's a major greed issue. Many of them have taken steps to make emulation itself completely illegal, which would be such an abuse of government authority that it rather invalidates any arguments against ROMs based on “moral” or “ethical” grounds, since holding civil liberties hostage at corporate or economic whim is probably not ethical, and one who is flagrantly unethical has little validity to impose moral censure on others. But then, we've seen it before when lobbyists tried to make mpegs illegal, simply because the record industry might lose money, and without any regard to the technological implications of outlawing algorithms for being too efficient, let alone the civil libertarian issues involved.
Nevertheless, every now and then some fool makes a big fuss over emulation and how immoral it is, and tries to spoil everyone's fun, so we're forced to distribute games underground. I've always considered copyright law to be illegitimate. I even opted out of becoming a professional programmer because I decided it would be immoral for me to write proprietary software, so you can imagine where I stand on this issue. Nevertheless, the world is swarming with particularly evil people in whom the money drive has taken hostage all forms of reason and compassion, and these people are legally allowed to lock you in an iron cage for five years if you get convicted. In addition to stealing your life, the feds can abscond with $50,000 (or perhaps more) for every count. How's that for thievery? Maybe “piracy” is a better name for how the government behaves than for the act of duplicating bits. But I digress.
Games, games, games! We can have so much fun as long as no one catches on. Fortunately, even if the Web goes down, so many people have stockpiled ROMs and burned them onto CDs that you can probably get them from anyone. But what can we do to protect our hobby?
One technique that works is cyber-squatting; no, not bad-faith domain name squatting, but merely claiming the unused “property” as our own by using it. People took over abandoned farms after the plague, and no one complained. By mixing their labor (<\#224> la ESR's perennial favorite, John Locke), they made the farms their own (and MAME was certainly a lot of labor). Or we can use the law of the sea, sunken-treasure metaphor, whatever ways we can possibly think of to justify it! If we continue in this vein for long enough, the so-called “property” will fall into public domain on account of disuse. (The squatter tradition ensures that wasted resources are put to good use, and in the case of video games, these wasted treasures could bring so much entertainment to so many.) Get ready for homesteading the arcade-o-sphere.
Another technique is one that was most effective in the DeCSS situation. One Slashdotter called it the “whack the mole” phenomenon, whereby every time one site is closed, two more pop up. (The name comes from a popular carnival game where in poor little plastic moles get bopped.) What with Don Marti's Great International DVD Source Code Distribution Contest, maybe we'll find some truly clever ways to get information passed around. As with DeCSS and mpegs, authoritarians soon found it was impossible to win, and either gave up (with mpegs) or lost (with DeCSS). Commercial forces will fight hard on this one, and the situation is a bit unclear, nowhere near as pure as the GNU/Linux movement. Maybe it will even make the movement look bad if we participate in ROM trafficking, but we as a society have an interest in seeing that these games are preserved. After all, they are part of the culture of a developing technology and relate much about our times.
If, of course, you believe in “intellectual property” and that copyright restrictions have to be respected no matter what, or you just don't want to commit felonies, what should you do? Well, rather than writing hate mail or telling the teacher, just ignore MAME and go develop some completely free wares under the GPL. If you really have to say angry things and call people “pirates” and whatnot, there is a place for people like you: Usenet.
For the rest of us, let's dig in (archaeologically/anthropologically speaking) and enjoy! www.mame.net
—Jason Kroll
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- UX Designer
- Senior Perl Developer
- Technical Support Rep
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- RSS Feeds
- Using an SMS Server to Provide a Robust Alerting Service for Nagios
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




9 hours 7 min ago
19 hours 47 min ago
1 day 1 hour ago
1 day 1 hour ago
1 day 3 hours ago
1 day 5 hours ago
1 day 12 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 20 hours ago