GBA HDMI Adapter + RGB output (WIP)

The place for all discussion on gaming hardware
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter (WIP)

Post by Woozle »

Once I drew it out I realized how awful 1.5x would look with nearest neighbor...basically end up line doubling every other row :(

In terms of gate usage, a bicubic interpolation algorithm implemented on a Virtex IIpro fpga uses 890 CLBs (logic blocks...also pretty sure it's scaling from 640x480) and needs about 3.5ms for execution.

From a rough comparison I'm using an Artix-7 where even the lower end models have about 5000 logic slices. Lets say the bicubic scaling uses ~1000 CLB, for virtex that's about 4000 slices. A logic slice in virtex is basically a single 4-input lookup table, a logic slice in the Artix-7 has four 6-input LUTs. So I would think the Artix FPGA series lower end chips could handle proper scaling in terms of logic capacity, I think the bottleneck would be memory as I could see a scaling algorithm eating up tons of BRAM. That's a super basic comparison, so chances are it's not valid but better than nothing.

Actually implementing a real scaling algorithm would likely take me months to figure out. I've done edge detection with an FPGA, but that's a pretty simple filter.


Always open to suggestions, I'm hoping this weekend I have a chance to sit down and try out some of these ideas.
Last edited by Woozle on Mon Mar 21, 2016 4:24 pm, edited 2 times in total.
User avatar
Guspaz
Posts: 3146
Joined: Tue Oct 06, 2015 7:37 pm
Location: Montréal, Canada

Re: GBA HDMI Adapter (WIP)

Post by Guspaz »

Even with some sort of interpolation filter, 1.5x scaling isn't going to look good, it's going to be very fuzzy... Even if you do a filter that sort of combines nearest neighbour with bilinear, where you basically output the original pixel value and only blend on the borders, it's going to look bad. Just looking at scaling on the vertical axis, even scanlines would be the original value, and odd pixels would be a 50% blend between scanlines. That's why it's better to just windowbox the image, and leave it up to the user to either display at the original size, or use their display's built-in zoom functionality.

At higher resolutions, like 1080p, this matters a lot less. Bilinear is still fuzzy, but the output pixels are so big that nearest neighbour looks fine, and the blending-on-edges approach looks almost flawless.

I should clarify that: 160 -> 1080 is 6.75x, so that means that three quarters of output pixels will be scaled 7x, and one quarter scaled at 6x, and that's a difference that's really hard to spot, at least in still screenshots. Alternatively, you do a 6x integer scale and windowbox, because at that point the window box is very small.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter (WIP)

Post by Woozle »

Really good points, thanks.

My PVM is a 14N6U, from what I remembered it is pretty lacking in adjustment options. Do you have a link to a good manual for it? Also, do you have any idea if it supports 480p?
User avatar
Guspaz
Posts: 3146
Joined: Tue Oct 06, 2015 7:37 pm
Location: Montréal, Canada

Re: GBA HDMI Adapter (WIP)

Post by Guspaz »

It doesn't support 480p. I'm not very familiar with that model (although I have several 14N5U at home), I know the N-series was some sort of budget model that has very few buttons on the front. I don't know if it has the underscan option, probably not.
User avatar
bobrocks95
Posts: 3471
Joined: Mon Apr 30, 2012 2:27 am
Location: Kentucky

Re: GBA HDMI Adapter (WIP)

Post by bobrocks95 »

A window-boxed option would look much nicer and that's why various programs use it. The Gameboy Player for instance looks pretty bad when you zoom the screen, so considering that it would take you months probably isn't worth the effort at all.
PS1 Disc-Based Game ID BIOS patch for MemCard Pro and SD2PSX automatic VMC switching.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter (WIP)

Post by Woozle »

I'm definitely going to try just sending a window-boxed video to my crt as a first attempt since it would be very straight forward. These different nearest neighbor "scaling modes" would be really easy to try out as well, I'll just see how they look for the heck of it.
User avatar
Extrems
Posts: 540
Joined: Sat Jan 30, 2016 5:01 pm
Contact:

Re: GBA HDMI Adapter (WIP)

Post by Extrems »

bobrocks95 wrote:The Gameboy Player for instance looks pretty bad when you zoom the screen, so considering that it would take you months probably isn't worth the effort at all.
It goes from 2x point to 2.375x bicubic. This is slightly obfuscated by deflickering (also present in native 480p), but the characteristic ringing is still visible.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter (WIP)

Post by Woozle »

I had a chance to work on this again. For the GBA to RGB/PVM I decided to use this board (had to use the Nexys for class project),

http://i.imgur.com/yiIO4AB.jpg

It works pretty well so far, I ended up not using the DAC shown on the breadboard (terrible quality) and went with just resistors for now. The colors are way off. Used incorrect resistor value for the "DAC" (it was dark and I thought all the resistors in my pile were same value, they weren't and it's throwing off color balance.)

Anyway, here is a close-up of the TV

http://i.imgur.com/Wohk7rF.jpg

And a link to a video just to show how much of the screen it fills.

https://www.youtube.com/watch?v=oWOzuWT ... e=youtu.be

This was just a quick and dirty implementation because I had some free time today. As far as potential issues,

-I've never sent video to a CRT from FPGA. For CSYNC I basically copied a sega Genesis CSYNC signal as best as I could based on my oscilloscope reading. I haven't checked my final timings yet so there's a good chance they're off by a little bit.

-didn't get around to clocking FPGA from GBA crystal. Write and read clocks to the frame buffer are pretty much independent, haven't seen many side effects yet.

-When sending a raw 240x160 frame to the TV it basically gets line doubled vertically it seems due to being shown on every other scan line. I went ahead and doubled it horizontally, it looks decent to me but I'm not 100% if that's correct aspect ratio.

Open to suggestions of things to look into.
User avatar
Guspaz
Posts: 3146
Joined: Tue Oct 06, 2015 7:37 pm
Location: Montréal, Canada

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Guspaz »

If the reads and writes are independent, then you should be seeing rolling tearing on horizontal movement. Try a sidescroller to see what I mean.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

Tested Super Mario Land 2 and Sonic Advance just now (it was the worst with tearing on a Game Boy to VGA) and I didn't notice any tearing. I'll look more carefully in the morning, I think I've been staring at that TV for too long.

Here's another picture (sorry for more botched colors)

http://i.imgur.com/jGOhWL4.jpg
User avatar
Guspaz
Posts: 3146
Joined: Tue Oct 06, 2015 7:37 pm
Location: Montréal, Canada

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Guspaz »

You're not sending 59.97 Hz to the CRT, then?

It does look quite nice.
User avatar
Unseen
Posts: 724
Joined: Sun May 25, 2014 8:12 pm
Contact:

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Unseen »

Guspaz wrote:If the reads and writes are independent, then you should be seeing rolling tearing on horizontal movement. Try a sidescroller to see what I mean.
It may not be that noticable. I have also experimented a bit with GBA-to-monitor conversion more than a year ago and even though I knew that there had to be tearing I initially did not notice it(*) until I went through a video capture and looked for it. The following are three consecutive frames from that capture:
Spoiler
Image
The tearing is spread over multiple lines because I used line tripling with an 800x600 output resolution - the output catches up to the GBA, then falls behind again because it reads the same video line from the buffer two more times, catches up again during the next line, falls behind etc. until it is far enough ahead that it doesn't hit the part of the buffer that is currently updated.

(*) "Once you see it, you can never unsee it" ;)
Last edited by Unseen on Fri Apr 01, 2016 12:10 pm, edited 1 time in total.
meneerbeer
Posts: 50
Joined: Thu Mar 26, 2015 9:14 am

Re: GBA HDMI Adapter + RGB output (WIP)

Post by meneerbeer »

I have a similar experience to Unseen. I once created a HDMI adapter for N64 with a single framebuffer and also did not notice tearing. Output framerate was around 60Hz (definitely not exactly 59.96Hz) and input framerate around 61Hz (due to playing NTSC on PAL console).
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

I didn't check my final timing but it would be out of pure luck if it ended up 59.97. Changing the timing is just a matter of changing some counter values and/or the PLL clock output, I'll tweak it.

edit: After going back and forth with it. When I looked at it again, I found there was stuttering. The vsync was off due to an error in my math. Now that I made the vsync what I assume to be 59.97Hz (based on 12.27MHz pixel clock) and I get tearing :/ The GBA sure is a pain. Going to try clocking the FPGA from the GBA crystal when I get some free time and order an inverter.

Thanks for the discussion and feedback.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

Been a while since I've updated. Made a custom VGA pcb for my fpga to send 240p to my TV and an input module for a snes controller. Still need to work on timing.

https://www.youtube.com/watch?v=GKq6risSOb8

http://i.imgur.com/AtUdYMC.jpg
User avatar
CkRtech
Posts: 668
Joined: Mon Aug 27, 2012 9:30 pm
Location: Seattle, WA

Re: GBA HDMI Adapter + RGB output (WIP)

Post by CkRtech »

Nice work. Following you on this one. Maybe someday I will hop into the pool for this sort of thing. The resources for it now are certainly better than they ever have been.
User avatar
AndehX
Posts: 790
Joined: Sun Oct 18, 2015 11:37 pm

Re: GBA HDMI Adapter + RGB output (WIP)

Post by AndehX »

This is great. If you ever get to the production stage, I'll definitely be first on the list to buy one of these.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

Just wanted to give a small update.

I was able to get the HDMI output 99% stutter free (I can't notice any) and frame tearing doesn't occur until the system has been running for ~25 minutes. When the 25 minute mark hits, frame tearing is present for several minutes.

I'm confident I can make it so that instead of 25 minutes no tearing -> several minutes of tearing -> 25 minutes no tearing....I can have it be 25 minutes of no tearing -> very slight hiccup -> 25 minutes no tearing.

Output resolution is 720x480 via line tripling. Scanlines can be set to line 1 or 3 of the three line copies.

I just finished designing an FPGA board with an HDMI output. It's a single PCB which handles the SNES controller input and all connections to the GBA. My plan is to eventually change it to DVI so I can send both 720x480p digital, and 240p analog on the same connector. I have just enough spare I/O so I think analog + digital has a good chance of working.

So fingers crossed that the FPGA boards work...in the mean time I uploaded some more videos (sorry, phone videos). The only video where I've implemented the tearing fix is the Sonic waterfall video, on youtube it looks stuttery but in person it's very smooth.

https://www.youtube.com/channel/UC3yx8N ... GOl5pXNMGg
RGB0b
Posts: 543
Joined: Wed Dec 05, 2012 1:52 pm

Re: GBA HDMI Adapter + RGB output (WIP)

Post by RGB0b »

Wow, awesome update!
User avatar
FinalBaton
Posts: 4461
Joined: Sun Mar 08, 2015 10:38 pm
Location: Québec City

Re: GBA HDMI Adapter + RGB output (WIP)

Post by FinalBaton »

Very nice indeed :)
I'll be following this project closely
-FM Synth & Black Metal-
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

Some displays don't handle the 720x480p signal very well. On my sony tv it results in a slightly narrow image, same on an asus vg248qe monitor. On an LG TV the image is cropped no matter what aspect ratio setting is chosen.

The aspect ratio seems correct on an asus pq279q, all of the following pictures were taken from the pq279q. The last zelda image is from the vq248qe. http://imgur.com/a/O40Ba

I'm thinking a 1280x720p letterboxed mode would help for displays which don't like the 720x480 video.
juji82
Posts: 349
Joined: Sat Nov 16, 2013 3:05 am
Location: Tokyo, Japan

Re: GBA HDMI Adapter + RGB output (WIP)

Post by juji82 »

following this project!
User avatar
yxkalle
Posts: 135
Joined: Sun Feb 16, 2014 4:32 am
Location: Stockholm, Sweden

Re: GBA HDMI Adapter + RGB output (WIP)

Post by yxkalle »

Just a small question: why two clock sources?
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

There were originally two clock sources because the GBA clock is almost useless inside the fpga due to its low frequency.

One of my test hardware setups now uses a single frequency source for both the GBA and fpga. However further testing needs to be done to make sure this isn't causing any bad side effects.

The idea will be to offer two main modes, a 59.7275hz mode to match the GBA and a ~60hz mode which requires a small overclock to GBA. Even though I don't notice any audio pitch changes due to the overclock I still want to provide the option for running the GBA at the original frequency.
tacoguy64
Posts: 546
Joined: Tue Dec 30, 2014 12:42 am

Re: GBA HDMI Adapter + RGB output (WIP)

Post by tacoguy64 »

Just want to add to what everyone else is saying, this is looking pretty nice.
User avatar
bobrocks95
Posts: 3471
Joined: Mon Apr 30, 2012 2:27 am
Location: Kentucky

Re: GBA HDMI Adapter + RGB output (WIP)

Post by bobrocks95 »

Sweet jesus I didn't expect it to look that good. I think it looks leaps and bounds better than even the low-lag version of GBI on a CRT with component cables.
PS1 Disc-Based Game ID BIOS patch for MemCard Pro and SD2PSX automatic VMC switching.
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

1280x720 output seems to fix/improve the aspect ratio. GBA scaled to 960x640. Tradeoff is smaller image size.

Using the TVs zoom feature would be nice but my TV interprets it as a PC source and disables the +1/-1 sizing options.

http://imgur.com/a/4ZGT8
User avatar
Fudoh
Posts: 13015
Joined: Mon Mar 06, 2006 3:29 am
Location: Germany
Contact:

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Fudoh »

Ouch (in regards to your scanlined Zelda image). On a 1:3 scale always put the dark scanline on top or bottom, but never in the middle...
Woozle
Posts: 232
Joined: Wed Jun 24, 2015 8:27 pm
Location: Florida

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Woozle »

Fixed http://imgur.com/a/VI8vN had scanlines set for line tripling mode, currently in 4x mode.

Thanks for pointing that out.

Also for the Zelda LTTP pics, the in game brightness setting was turned to max...I thought I had turned it to normal but guess not. Explains the overly bright pictures earlier.
Kilokahn
Posts: 9
Joined: Thu Apr 16, 2015 2:02 am

Re: GBA HDMI Adapter + RGB output (WIP)

Post by Kilokahn »

I am now following this forum, I would love to output GBA to the Framemeister.
Post Reply