News for hackers. Stuff that matters.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by mjn on Thursday April 19, 2012 @03:55PM (#3864785)
That's some pretty clean emulator code! Sticks fairly closely to the hardware design, and it's clear what's going on for the most part. In addition to practical use as an emulator, it might make a good learning tool for someone who wants to understand how the Atari VCS's weird hardware works. Perhaps read along with the canonical Stella Programmer's Guide (http://www.alienbill.com/2600/101/docs/stella.html) and the less technical but still informative book Racing the Beam (http://www.amazon.com/gp/product/026201257X/ref=as_li_ss_tl?...).

A minor quibble is that the audio emulation, while accurate from the perspective of what the audio hardware does, produces a bunch of harsh-sounding aliasing when used to generate digital audio. That's a common problem with 8-bit emulators, though. The short explanation of why: in the hardware implementation, the Atari feeds square waves directly into speakers. Square waves are in a sense the "natural" electrical signal for digital circuits, and from simple bit-patterns you can get complex harmonics. But when, instead of feeding them as voltages directly to a speaker, you generate digital audio samples that look like square waves, the harmonics above the Nyquist frequency (1/2 the sample rate) fold over into the audible range as aliasing artifacts.

The fix is to generate band-limited square waves, which are approximations to square waves w/ no frequency content above the Nyquist frequency. There's an active research literature on how to best do that efficiently (it's important if you're trying to digitally replicate the sound of classic analog synths like the Moog), but it mostly boils down to replacing the discontinuity in the square wave (which is where the harmonics come from) with something more like a ripple, designed to only produce sub-Nyquist harmonics. One fairly simple approach, integrated into several emulators, is explained here (w/code): http://www.slack.net/~ant/bl-synth/

Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Thursday April 19, 2012 @04:59PM (#3865116)
Thats an amazing observation mjn!!! I knew a little about the Nyquist frequency, but I didn't really hear much aliasing during development. Surely that is a good point to improve! Thanks.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by mjn on Thursday April 19, 2012 @05:17PM (#3865192)
To be fair it's not really a show-stopper in the context of Atari emulation, just a "nice to have". Most of the Atari's sounds are so noisy to begin with (e.g. the famous Combat tank rumble) that the aliasing is much less noticeable than if you're digitally emulating simpler waveforms, like the ones from analog synthesizers.

The most-used 2600 emulator, Stella, doesn't do bandlimited synthesis either, without many complaints. I believe z26 is the only Atari emulator that does, so listening to differences between how things sound in z26 and other emulators might be a way to figure out if it really matters. Though as far as implementation, z26 is 100% asm, so not very easy to use as a reference.

Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by cageface on Thursday April 19, 2012 @08:18PM (#3865876)
Probably the easiest way to solve the aliasing problem is to pre-calculate a series of square waves, each with successively fewer harmonics. You can then just select the right square wave for any given note and play it back via linear or polynomial interpolation. This is what I do in my iPad synth app.

The main downside of this approach is that it takes more memory, but it's very easy on the CPU.

Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by gaius on Thursday April 19, 2012 @05:20PM (#3865209)
I highly recommend the book Racing the Beam by Nick Montfort if you are interested in the development of early Ataris.

Also see http://www.bogost.com/games/a_television_simulator.shtml

Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by TazeTSchnitzel on Thursday April 19, 2012 @05:16PM (#3865190)
All sorts of weird sounds and glitching if you turn on without a ROM... is this a faithful emulation? Would the original Atari do that?
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Thursday April 19, 2012 @05:34PM (#3865265)
Yes... A real Atari does the same thing! That's what the processor and the other chips produce when the machine is started with no ROM to be executed. I tried to implement the emulation at the hardware component level as accurately as I could. It happened spontaneously!
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by TazeTSchnitzel on Thursday April 19, 2012 @05:51PM (#3865341)
Where does the randomness come from though?
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Thursday April 19, 2012 @06:02PM (#3865380)
When the processor tries to read the game program from the empty cartridge slot, it ends up reading random bytes from the data bus. Its like a random program commanding the video and audio hardware!
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by mitjak on Friday April 20, 2012 @06:52PM (#3870153)
That is the coolest thing I've ever come across.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Monday April 23, 2012 @03:38PM (#3880567)
That makes me very happy! Thank you.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by rollypolly on Thursday April 19, 2012 @04:16PM (#3864905)
I love stuff like that! I hope it isn't taken down by Atari's legal department. They're notoriously unfriendly towards hobbyists.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by mjn on Thursday April 19, 2012 @07:46PM (#3865792)
They don't like clones of games, but I haven't heard of emulators having any trouble. Stella (http://stella.sourceforge.net/) has been around for years without problems. Hopefully it'll stay that way!
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by pathdependent on Thursday April 19, 2012 @07:00PM (#3865644)
Thanks for the notice. I forked and downloaded it so I get to keep a copy.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Thursday April 19, 2012 @04:55PM (#3865091)
Me too...
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by sehugg on Thursday April 19, 2012 @06:45PM (#3865576)
Nice job! I was wondering the other day if anyone ever ported Stella to Java, but this looks simpler and ripe for hacks!
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by klauswuestefeld on Thursday April 19, 2012 @04:14PM (#3864894)
What about having to blow on the cartridge? :) Can that be emulated by blowing on the mic?
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Thursday April 19, 2012 @04:19PM (#3864925)
Yes I could do that... :-) But try turning the console on without a cartridge, or change cartridges with the console still on...
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by weirdkid on Thursday April 19, 2012 @09:23PM (#3866077)
There is a Java port of Stella -- I converted it to an applet for a buddy of mine back in 1999. Get it here: http://weirdkid.com/jstella
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by kalecserkurtz on Thursday April 19, 2012 @04:02PM (#3864820)
Nice job!

Maybe someone could create a PlayN version so it will run on the browser and on Android.

Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by bdunbar on Thursday April 19, 2012 @10:38PM (#3866276)
You know ... Defender _now_ is not nearly as visually cool as it was _then_.
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by PauloMagalhaes on Thursday April 19, 2012 @06:00PM (#3865375)
awesome ;)
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ppeccin on Friday April 20, 2012 @05:54PM (#3869963)
Thanks!
Re:Javatari - multiplayer Atari 2600 emulator written in Jav... by ifnazar on Thursday April 19, 2012 @04:00PM (#3864807)
very cool