I've always wanted to fiddle with a Vectrex, and surely Laptop + Oscilloscope = Ghetto Vectrex! And the first games were on oscilloscopes anyway, so that's wonderful too.
I wrote a simple game in a couple of days over Christmas. The most vectory vector game of all, the obvious one: a copy of Asteroids! If you've not played Asteroids before, here's the rules. Writing something to output audio data in realtime isn't so hard. Base SDL by itself doesn't really give you any audio primitives except that; you need a library like SDL_mixer if you want a pre-constructed system that can play sound effects and stream music.
The game software renders visible objects into an array of line segments (pairs of float pairs) on an internal screen. At the end of every frame, this list is changed into an array of audio samples compatible with the audio output. When the audio buffer callback happens, it selects the unused previously filled audio output array (it's double buffered) and populates the output buffer with copies of the converted data until its completely filled.
You can either render the raw floating point lines to the screen (these are the green pics below), output the contents of the audio buffer to the screen (this would be quantised to fit into the format of the audio buffer, I'm using unsigned bytes), or, if you're feeling adventurous, just listen to the audio buffer. Each of the screens in game has its own particular pitch due to the way the constructed audio buffer loops through the original line list: the more stuff on screen, the longer the period and the lower the pitch. You can also hear the objects moving through the field, it sounds like phasing.
The next Maker Night... it's time to see if this thing even works. There's a few things that might happen. It might come out backwards, or unbearably flickery, or just a squiggle, or the oscilloscope might blow up, or my laptop might blow up.

The place is not short on oscilloscopes! This isn't even all of them.
What we need is a calibration screen. Something the extends to the border so you can scale the picture properly, and something with readable text so you can tell if the picture's flipped.

There we go. Let's see if my code to render the internal line buffer as stereo audio data works...

NAILED IT.
Those wavy lines in the background are the oscilloscope cursor trying to draw the diagonal lines after drawing the border. The cursor flies off and wobbles about instead of resting suddenly. I think what I'm seeing is inductance, either from the scope itself from moving the cursor or the probes themselves (But wouldn't I have seen it on the christmas message? That thing was crystal clear.). That leaves the laptop itself or the sliced up bit of speaker cable I'm using to connect it to the probes.

Who doesn't want to see their name in lights?

To aid the scope in drawing lines, I'm now sending the cursor slowly down the length of each line (20 locations seemed to work the best). The wobbling cursor is very obvious here, the text sort of looks hand-written. My original plan was to alternate between the endpoints of each line, but that was phenomenally crap. I tried increasing the sample rate, but then the entire image was one hilarious distorted circular mess.

Woooo!

Hey, where'd my asteroids go?
If the buffer isn't large enough to hold all the drawable things, the things that are last on the list won't get drawn. That's only really a problem when complex items like text are on screen as they're composed of a ton of lines. Before I added the slowly-iterate-down-each-line stuff, there was tons of space in the audio buffer for everything.

Bingo! No denying it, that's Asteroids!
You can still see the effect of inductance at the start and end of every object as the cursor leaps off and slows down to draw the next object. The extra lives are just three triangles constructed of three lines in the lower left, and the cursor doesn't even attempt to show them right.

...but there is a lot of stuff missing from the screen. The score and highscore captions were completely illegible and distored the screen horrifically so they're gone now.
The glowing border is there to keep the screen centred. (I got the idea for the border from this guy. Everybody's doing Asteroids, hooray!) The display tends to float around, as if it's trying to keep everything centred. When an asteroid floated off the side of the arena, the whole image would jump. I think that's the result of capacitance. Drawing objects multiple times to make them more distinct was a bad idea: as the image floated around, the repeated object would leave a large glowing trail behind it.
I tried looking for an oscilloscope with some different probes, but no luck. There's probably a more accurate way to set up the scope for measing signals like this, but I didn't look too far into it. Considering how well the Arduino Duo message worked, I think I'm at the limits of my laptop's sound hardware than anything else.

And that's the story of how I tried to coerce a piece of antiquated oceanographic analysis equipment into an action packed intergalactic adventure.





