Offline
CA

I'd like to 'stream' video from a DMG or a Pocket into my laptop. I know it can be done with FPGA, but I don't want to get into it unless I absolutely have to.

What we need is basically an interface fast enough to send bits to the PC.

We have 5 (0V-5V) outputs from CPU which are (1) Clock, (2) Horizontal Sync, (3) Vertical sync, (4) Data 0, (5) Data 1

We could either stream bits with 4M Bps (since the clock speed is 4MHz) of course half of the time there's no useful data but it's just a rough estimate.

Or we stream the whole frames with 160*144*2*60 bps that is 350K Bps.

Arduino Due and Teensy appear to have more than enough clock speed and memory to handle this. The question is what interface will do the job? Serial and UART won't work, USB HID is manageable with huge frame loss - this option is highly undesirable.

The very best solution would be to use the same protocol as webcams. Thus we won't need additional drivers and stuff. But I can't find the spec.

Alternatively it's possible to build an ad-hoc interface and write a driver, but this won't be cross-platform.

Ideas?

Last edited by friendofmegaman (Apr 16, 2014 2:54 am)

Offline
CA

WiFi or Ethernet?

Last edited by friendofmegaman (Apr 9, 2014 2:17 am)

Offline

Have you thought about a live video feed? NeX did something with a Super Gameboy. But I'm not sure what. I'm quite interested in this aswell. But I need the feed to be A/V not data.

Here it is: http://nex.gg8.se/modblog/2010/04/gameb … o-casette/

Offline
Michigan

Don't buy a Due, but the Teensy 2.0 for $16 and see if you can't work with the port manipulation (DDRD) for the 5 inputs because this would be the fastest. Serial over USB may actually be fast enough to send something...why did you think it would not work?

Offline
CA

I saw this mod by NeX. What he did is modded an SNES and a Super GameBoy and crammed everything into a video cassette. This approach will definitely give you the best picture with the SGB frame, colors in some games and other extras. It's a brilliant idea and definitely a way to go for TV output especially now when there are loads of cheap SNES clones (in the end of a day you don't need authentic Nintendo hardware for that apart from Super GameBoy cartridge).

However I don't want to just reproduce it since it was already done. I'd like to try something new. I haven't seen a decently working capture device so far. I know that snesy (an FPGA guy from Germany) works on the similar project, but I'm not sure if he actually finished it, I found it quite hard to contact him.

Anyways, I don't think an FPGA and SNES are the only options. My ultimate goal is to get the 'raw' pixel data to PC where I could mess with it. Play with extrapolation, add color, try various effects etc.

If you like Arduino you could try this library. With the powerful enough board you might be able to draw pixels on the screen. But it will be monochrome, while SNES mod is way better smile

Last edited by friendofmegaman (Apr 9, 2014 2:49 am)

Offline
Michigan
friendofmegaman wrote:

If you like Arduino you could try this library. With the powerful enough board you might be able to draw pixels on the screen. But it will be monochrome, while SNES mod is way better smile

The way I see it is that you could use an AVR uController for taking the data and sending it to a second AVR for converting it to video, composite or otherwise.

Lets take a moment to read over the FPGA C program:
https://raw.githubusercontent.com/flash … ndOscope.c

Offline
Michigan

Wait ...where is uh....the FPGA? All I see if an xmega128. nice. big_smile

EDIT: Rival-corp was doing the FPGa stuff, but the site is a redirect to spam now... sad

Last edited by Jazzmarazz (Apr 9, 2014 3:00 am)

Offline
CA
Jazzmarazz wrote:

Don't buy a Due, but the Teensy 2.0 for $16 and see if you can't work with the port manipulation (DDRD) for the 5 inputs because this would be the fastest. Serial over USB may actually be fast enough to send something...why did you think it would not work?

Yah, you're right, it can actually... for some reason I had and old crappy RS232 in mind o_O

Jazzmarazz wrote:

Wait ...where is uh....the FPGA? All I see if an xmega128

Doesn't seem like and FPGA to me.  But it's just a DAC to feed the oscilloscope, I don't see much use for my project.

Anyways I have an UNO board which is 16MHz I'm not sure it will suffice to transmit 4M bps

Last edited by friendofmegaman (Jul 17, 2014 8:38 pm)

Offline
Michigan
friendofmegaman wrote:

Doesn't seem like and FPGA to me.  But it's just a DAC to feed the oscilloscope, I don't see much use for my project.

Yes, the DAC goes to the Scope, but if you were to drop the DAC and receive the data with a video converting micro controller then it would in fact be useful to you. Said data might need to be modified in code, but it could be worked out at some point. I still have to look through the code some more.

Offline
Michigan

Also, that 'DAC' is just a few series-parallel resistors with an op amp for summing a couple of the signals.
Composite video by definition is nothing but a mash up of everything as well, so he should already be pretty close to having it.

Offline
CA

It seems that serial over USB can actually send data quite fast. May be I can actually forward bits to PC...

Last edited by friendofmegaman (Apr 9, 2014 4:18 am)

Offline
Melbourne, Australia

...if you want ease-of-use and cross-platform-compatibility on the computer side, then you could take an old PS2 EyeToy webcam which contains a OV519 camera-to-USB processor, and then use your Arduino to take the GameBoy's video data and bend it into a format that matches what the camera sensor sends into the OV519!

Offline
CA
uXe wrote:

...if you want ease-of-use and cross-platform-compatibility on the computer side, then you could take an old PS2 EyeToy webcam which contains a OV519 camera-to-USB processor, and then use your Arduino to take the GameBoy's video data and bend it into a format that matches what the camera sensor sends into the OV519!

This sounds like an interesting idea, but I think it's way too complicated. There should be easier way to do it. I just haven't found it yet smile

Offline

I read this thread with great interest as I am working on a similar project myself.  I am interested in recording video directly from the Game Boy, rather than streaming it to a PC. I hope to eventually build a portable solution that isn't tethered to a computer.  Nonetheless, my first step will likely be to read the data with a Teensy 3.1 and send it to a computer over USB so that I can capture and analyse some frames (this saves me buying a logic analyser).

I think the Teensy is a good choice as it is cost-effective (especially compared to Arduinos) and reasonably fast.  I'd like to avoid FPGAs if possible, simply because I've never worked with them before and it looks as though the learning curve is quite steep. Nonetheless, it seems like if we use the same chip our projects could share some code, which I would be happy to do, although this may be slow going due to my work commitments.  What follows are a few thoughts I've had so far which might help you out.

[Edit, 2014-04-26: To anyone reading this thread from the start: The Teensy 3.1 is proving to be a less suitable board than I had anticipated, and so I would no longer recommend it for this application without reservations.  See pp. 5-6.]

The basic idea of connecting a Teensy would be to put the clock signal on an interrupt and use port manipulation to read the two data lines (as Jazzmarazz suggests).  It may be desirable to also use interrupts for VSync and HSync.

I initially suspected that the effective framerate of the Game Boy would be lower than the refresh rate, but having done some investigation it seems that this is not the case.  This means that we do need to be able to handle around 60 fps if we don't want to drop frames.

The Game Boy's LCD receives data at 4.19 MHz (the Game Boy's CPU clock).  The screen resolution is 160x144 px with a bit depth of 2 bpp (as you point out), and the VSync is 59.73 Hz.  This means that while we need to capture the data at 4.19 MHz, we only need to transmit it at around 2.75 Mbps if we send the raw data.  The Teensy apparently transmits serial data at USB Full Speed (12 Mbps) (although I have not tested to see if it can maintain these speeds), so this is well within spec.  Since the clock speed is fast relative to the resolution and refresh rate, it means there must be some dead time in between pixels (about a third of the time is spent actually transmitting pixels).  This time seems to occur at the end of each line and lasts about 78 µs, giving the microcontroller time to do other processing.

The Game Boy LCD is driven with 5V logic.  It is worth noting that only the Teensy 3.1 has 5V tolerant inputs; the Teensy 3.0 does not (I don't know about the older ones), meaning that you would need to add a voltage divider (although this is trivial).  Also, on the subject of voltage, as Craig of Flashing LEDs points out, "be careful of the -30V DC contrast signal," which can be found on the LCD connector.

You mentioned making a device which uses the same protocol as webcams.  USB Webcams are USB Video Class Devices, the specification is here: http://www.usb.org/developers/devclass_ … ss_1_5.zip, but it would be a lot of work to implement this on a microcontroller.  I think that writing a (userspace) driver would be a much better option, but if you really want a device that doesn't need custom drivers, you could output a video signal and then feed it into a USB video capture card (although there would be some loss in quality with this approach).

Anyhow, for reference, here are some links to the relevant research (which you have no doubt seen, but will be of interest to others reading this thread).  Possibly more to come.

Gameboy VGA Adapter (Rival-Corp) [archive]
http://web.archive.org/web/201206110330 … adapter-2/

Intercepting the Gameboy LCD (Flashing LEDs)
http://flashingleds.wordpress.com/2010/ … meboy-lcd/

NintendOscope (Flashing LEDs)
http://flashingleds.wordpress.com/2011/ … endoscope/

Gameboy Classic VGA-Adapter (snesy)
http://circuit-board.de/forum/index.php … A-Adapter/ [German]

Last edited by rvan (Apr 26, 2014 8:53 am)

Offline
CA

Thanks for sharing. Yah, webcam protocol is way too long to implement (although not completely impossible).

As for signal processing. I have this in mind now:
1. Get the signals to Teensy (I haven't ordered it yet though, but I'm playing with Arduino UNO as proof of concept)
2. Update line and offset (a pixel in a line) as needed. Edges can be detected as clock==0 && clock_prev==1 (for rising edge) the other way around would be for the falling edge.
3. And then I'm hoping to be able to make a frame inside the microcontroller this way we'll save on bandwidth (which is not that relevant of course if we have 12 MBps) and take some work off the PC (which again maybe not necessary given the computational power of the modern PCs). To make a frame we need 160*144*2 bits, which can be represented as unsigned char buffer[5760] or unsigned int buffer[1440]. I'd go with a one dimensional array holding a frame as an unfolded matrix. Two dimensional is possible but it will take more RAM (since each pointer will take 1 byte in case of Arduino) and I want to preserve as much as possible in case I need it.
4. On the PC side I'm thinking of using (at least kick start with) pyGame - an SDL binding for python. Looks cross-platform enough for me. PySerial can be used to grab data from USB.

But I need to have my Teensy to test that smile

Last edited by friendofmegaman (Apr 16, 2014 2:59 am)

Offline
friendofmegaman wrote:

Edges can be detected as clock==0 && clock_prev==1 (for rising edge) the other way around would be for the falling edge.

This suggests you're planning to sample the clock.  I think it would be more robust to use an interrupt.

friendofmegaman wrote:

3. And then I'm hoping to be able to make a frame inside the microcontroller this way we'll save on bandwidth (which is not that relevant of course if we have 12 MBps) ...

Given that the dead time in terms of LCD data is at the end of the line, rather than the end of the frame, it might be more feasible to send the data one line at a time.  Also note that USB Full Speed is 12 Mbps not 12 MBps.

friendofmegaman wrote:

I'd go with a one dimensional array holding a frame as an unfolded matrix.

If you're using a Teensy 3.1 I wouldn't worry about doing this unless it makes the execution more efficient (I'm not sure whether it will), as there is 64 kB of RAM (this is assuming you do store whole frames).

friendofmegaman wrote:

On the PC side I'm thinking of using (at least kick start with) pyGame - an SDL binding for python. Looks cross-platform enough for me. PySerial can be used to grab data from USB.

This is a good choice.  I've worked with Pygame before.