PDA

View Full Version : DIY: FPGA MDA/EGA/CGA to VGA Converter :D



Retro Canada
September 28th, 2017, 06:09 AM
Hello guys, this is my last project Iíve been working this month:

A truly FPGA MDA/CGA/EGA to VGA Converter. And it will be open source.


First, few answers before watching the video:

1) No, I am not selling this. I am designing it. It will be available later as DIY and open source.
2) Itís a W.I.P. I need to add MDA support now
3) Itís purely DIGITAL. No, your Amiga, Apple GS wonít work
4) Being DIGITAL itís tied up to the EGA-MDA and CGA pixel clocks: 16.257Mhz and 14.318Mhz. Anything different than that, like your ZX-Speccy 128 will look jagged and jittered. Not to mention the sync pulse polarity that must match the EGA/CGA.
5) It converts CGA and outputs as 640x400@70Hz (21.175Mhz). For EGA it uses 640x350@70Hz (21.175Mhz). These are VESA standard resolutions supported by a standard VGA monitor. Your fancy new HDMI monitor probably will give a middle finger to that.
6) For MDA it will use 720x350x70Hz another VESA.
7) There is no HDMI output and it wonít have it.
8) There are no margins the signal is displayed in 640x350/400. Some programs like ChekIt changes the CGA 6845 registers and mess up with the borders. For that in CGA you can use a DIP switch to fine adjust the screen. This problem doesnít seem to happen in EGA.
9) Iím testing with my boards. There could be variations
10) I still need to solve some race conditions in EGA that causes it to make very hard to add changes. Too many lines being written/read at same time. But the video is stable.
11) You will be able to change the resolutions like output in 800x600, provided you can change the FGPA design and add new pixel clocks and solve many *ISSUES* it may cause :D hey itís fun! But there wonít be scale-up, unless you implement it in FGPA >:) using linear interpolation. Right now the only scaling present is CGA where I double scan each line from 640x200 to 640x400.
12) Why am I doing this instead of using a GBS8200 ? Have you ever used that board ?

Enjoy the video:

https://www.youtube.com/watch?v=8_fl28-o9tE

Druid6900
September 28th, 2017, 07:55 AM
Yeah, I'd like to take a look at this, just from a repair depot point of view.

The less monitors I have on a work bench, the more computers can be worked on in a comfortable radius.

The ones we've looked at, so far, are either really bad or really expensive.

Stone
September 28th, 2017, 08:12 AM
The less monitors I have on a work bench, the more computers can be worked on in a comfortable radius.That's why I use a NEC Multisync. :-)

Druid6900
September 28th, 2017, 08:21 AM
Yes, I have an MDA/CGA/EGA capable monitor ( Taxan Multi-Vision 770) but, I have 6 workbenches and buying and having 5 more shipped would not be practical.

Trixter
September 28th, 2017, 09:21 AM
Sounds like a great project! It looks like your project is geared towards being able to easily use commodity monitors, based on this info:



5) It converts CGA and outputs as 640x400@70Hz (21.175Mhz). For EGA it uses 640x350@70Hz (21.175Mhz). These are VESA standard resolutions supported by a standard VGA monitor.
6) For MDA it will use 720x350x70Hz another VESA.
...
8) There are no margins the signal is displayed in 640x350/400.

Retro Canada
September 28th, 2017, 09:25 AM
There is an error for the MDA: the 720x350 is 85Hz IIRC.

SpidersWeb
September 28th, 2017, 09:27 AM
I want a 9 pin cable that I can blindly hook up, and it gets fed through to my LCD and capture hardware. I currently have this for VGA, so being able to go CGA/EGA/MDA to VGA is very helpful.

Excellent work on the project, I was experimenting with this idea myself using the internal Dual Port RAM on a Xilinx Artix 7 but could never quite get my internal timings done right and it kind of got put to one side. Also glad to see it's not a BGA part.
Looking forward to the MDA and the source/project files because I'd love to build one.

From memory with MDA I ended up playing with 720x400 and 720x350, on my test LCD these basically looked the same with the 350 mode just having black bars top and bottom. I never tried a CRT or the capture stuff, but figured if there was any issues it'd be fixable with vertical height adjustment.

Retro Canada
September 28th, 2017, 09:35 AM
I was experimenting with this idea myself using the internal Dual Port RAM on a Xilinx Artix 7 but could never quite get my internal timings done right and it kind of got put to one side. Also glad to see it's not a BGA part.
Looking forward to the MDA and the source/project files because I'd love to build one.


I guess you don't have enough RAM bits inside the FPGA (well maybe MDA using 2 bits per pixel you need 63K). but since I need 6-bits per color this is why I use an external SRAM chip of 8ns! I use the dual port ram only the for incoming and outcoming rows.

You don't have to solder the FPGA Cyclone, you just buy the smal CoreEP4CE6 from ebay, it costs 25 dollars and it comes ready to use. You just need to build the daugherboard I designed to use with it.

Stone
September 28th, 2017, 10:41 AM
Yes, I have an MDA/CGA/EGA capable monitor ( Taxan Multi-Vision 770) ...No VGA capability?

Scali
September 28th, 2017, 10:42 AM
I believe a "Shut up and take my money!" is appropriate here :)

SpidersWeb
September 28th, 2017, 11:24 AM
I guess you don't have enough RAM bits inside the FPGA (well maybe MDA using 2 bits per pixel you need 63K). but since I need 6-bits per color this is why I use an external SRAM chip of 8ns! I use the dual port ram only the for incoming and outcoming rows.

You don't have to solder the FPGA Cyclone, you just buy the smal CoreEP4CE6 from ebay, it costs 25 dollars and it comes ready to use. You just need to build the daugherboard I designed to use with it.

You can get the Artix 7 with up to 2,700kbit of internal memory (mine was the 1,800kbit model), but with it being BGA and a little pricey per chip, I think the SRAM solution is much better. My issue wasn't hardware limited but mostly a lack of time, knowledge and skill.

KenEG
September 28th, 2017, 12:44 PM
The screens look a lot better than those I get using my C128 DCA /Gonbes 8220 combination and it sounds like it may be slightly cheaper. Very cool.

Plasma
September 28th, 2017, 04:24 PM
I bought a Gonbes about 5 years ago and it never worked right. So I'm looking forward to this :cool:

dJOS
September 28th, 2017, 09:56 PM
Cool project, I assume it's compatible with Tandy & IBM PCjr enhanced CGA too?

Scali
September 29th, 2017, 01:22 AM
Cool project, I assume it's compatible with Tandy & IBM PCjr enhanced CGA too?

I would assume so, since they use the same 16-colour RGBI interface to the same monitor (640x200 resolution).
The enhancements are only in the display circuitry, which can display 16 colours at a time, where CGA is limited to 4. EGA is the same, in 320x200 mode, it can be used on a regular CGA monitor.

Druid6900
September 29th, 2017, 06:12 AM
No VGA capability?

No, VGA monitors was not something I was short of and KVM units took care of having to have lots of them.

vwestlife
September 29th, 2017, 06:28 AM
8) There are no margins the signal is displayed in 640x350/400. Some programs like ChekIt changes the CGA 6845 registers and mess up with the borders. For that in CGA you can use a DIP switch to fine adjust the screen. This problem doesnít seem to happen in EGA.
CGA software often makes use of the border color, so I'd miss it if it wasn't shown at all. I know it's impractical to make the border go all the way into the overscan area like real CGA did on a CRT monitor, but VGA at least displayed a thin border on CRT monitors.

Stone
September 29th, 2017, 06:37 AM
No, VGA monitors was not something I was short of and KVM units took care of having to have lots of them.Once again... the NEC Multisync also does VGA so it's a one fits all solution. :-)

Retro Canada
September 29th, 2017, 07:08 AM
CGA software often makes use of the border color, so I'd miss it if it wasn't shown at all. I know it's impractical to make the border go all the way into the overscan area like real CGA did on a CRT monitor, but VGA at least displayed a thin border on CRT monitors.

There are no pixels left. Unless I shrink it or use a higher resolution like 720x400 but then you'd lose on aspect ratio and would end up with huge left and right borders.

new_castle_j
September 29th, 2017, 03:24 PM
Magnificent! I will be waiting for the release so that I can make my own!

Plasma
September 29th, 2017, 06:55 PM
There are no pixels left. Unless I shrink it or use a higher resolution like 720x400 but then you'd lose on aspect ratio and would end up with huge left and right borders.

Doesn't VGA have pixel borders as part of the signal? Keen 4 has color overscan when run on a VGA so it must be possible. Though it will probably only show on a CRT.

Retro Canada
September 29th, 2017, 08:49 PM
Doesn't VGA have pixel borders as part of the signal? Keen 4 has color overscan when run on a VGA so it must be possible. Though it will probably only show on a CRT.

Look at your PC screen right now. Do you see any overscan ? Every VGA monitor is like that. Pixels used to be more expensive, there is no waste.... CRT monitors do have overscan due to the nature of the CRT.

VileR
September 30th, 2017, 01:13 AM
Or, one could cook up a 720x480 mode and center the 640x400 active area within it, with the rest being the overscan color. Aspect ratio *and* border width would still be quite close to the real deal on CGA/EGA - and the best part, a 480-line mode would get you true 60Hz as well. :)

Scali
September 30th, 2017, 02:16 AM
Doesn't VGA have pixel borders as part of the signal? Keen 4 has color overscan when run on a VGA so it must be possible. Though it will probably only show on a CRT.

Yes, VGA specifically has a border area between the horizontal blank and the active window, which can be adjusted by the extended CRTC registers. The border can be any colour, the horizontal blank is always black (I believe CGA and EGA have the border colour in the horizontal blank as well).
For some reason, most LCD screens seem to cut that off completely.

Retro Canada
September 30th, 2017, 02:39 AM
Here in first hand: MDA working. The MDA I'm taking from my EGA Gemini VC-01 generic as Graphmaster Plus or whatever. I'm waiting for my original IBM MDA to arrive. One thing is about the border, some tools like checkit and games they change the CRTC registers and mess with the borders, it will move the text to the left (or right). So I think we need a little tool to reset them back. The video: https://www.youtube.com/watch?v=g4NCncDdVf8

Retro Canada
September 30th, 2017, 02:41 AM
Or, one could cook up a 720x480 mode and center the 640x400 active area within it, with the rest being the overscan color. Aspect ratio *and* border width would still be quite close to the real deal on CGA/EGA - and the best part, a 480-line mode would get you true 60Hz as well. :)
Since I will open the code you can change it the way you want. But it's is very hard to make something work when you have the 3 inputs running. The FPGA begins to fail. So adjusting it is hard and requires lot of skills. Honestly I don't like overscans. It looks tiny, for the sake of border ? Why do you want borders ? I see no reason... The only use for borders for me is as debug purpose as you can change it on the fly...

Great Hierophant
September 30th, 2017, 06:32 AM
Games like Crystal Caves and Secret Agent would change the border color based on events in the game, so preserving some border is important.

Plasma
September 30th, 2017, 08:59 AM
Look at your PC screen right now. Do you see any overscan ? Every VGA monitor is like that. Pixels used to be more expensive, there is no waste.... CRT monitors do have overscan due to the nature of the CRT.

I'm not sure what you're getting at? Yes, LCDs don't show overscan. But CRTs do. I have a VGA CRT.

Retro Canada
September 30th, 2017, 02:19 PM
I'm not sure what you're getting at? Yes, LCDs don't show overscan. But CRTs do. I have a VGA CRT.

Regarding overscan some LCD monitors you can configure and change Clock, Phase and H and V Position. By default it cuts out any border. But changing the clock you lose real state for the borders and your text will look a little shrunk. Also you will need to change the FPGA code to send the borders because it will blank them out.

Other annoying monitors will try to re-calibrate to the new image so it's pretty unreliable. For example: you have commander keen with the cyan border, it will shirnk to it but when get to DOS black it will think it's just front/porch blank and re-stretch again.

I don't have a CRT VGA, so I cannot infer or make any test on that subject. For this reason I'm cutting out the borders. Cutting the borders as a normal PC VGA will work on any standard monitor.

Trixter
October 3rd, 2017, 07:37 AM
Because some games (and text-mode applications) use the border color to communicate with the user, I'd think it would be important to preserve the border. Even if you don't personally see the need for it, others do. It's a DIY project, so nobody is under any obligation to do anything, but at this stage of development, maybe ensure that what you're designing cannot stop others from adding border adjustments?

Retro Canada
October 3rd, 2017, 08:18 AM
Because some games (and text-mode applications) use the border color to communicate with the user, I'd think it would be important to preserve the border. Even if you don't personally see the need for it, others do. It's a DIY project, so nobody is under any obligation to do anything, but at this stage of development, maybe ensure that what you're designing cannot stop others from adding border adjustments?

You can change the EGA to output as 720x350@70Hz. (there is no 720x480 AFAIK) and include all the overscan you want. FYI the VGA DOS text screen is 720x400@70Hz, so any monitor will support it. But the aspect ratio will change.

I am setting the RESET button to search for the leftmost, topmost active pixel on screen and calibrate it. So if there is a border, it is there were the screen will be starting (if you press the RESET button).

Text screens, DOS, etc won't have any border color. I'm doing this because different vendors use different front/back porch as the CGA/MDA had no standard. On VGA by other hand they are pretty well defined.

You can change the FPGA to match the exact boot screen front/porch but some games will change it, thus the need for the button. You can use 800x600@60Hz but the image will look small with wrong aspect ratio.

My main concern is about the stupid 16Mhz hercules clones. Why did they had to change from 16.257Mhz ? I'll see if I can fix it digitally. Otherwise they will work but with jitter. I have a Tarmack 16Mhz in the mail.

vwestlife
October 3rd, 2017, 09:51 AM
My main concern is about the stupid 16Mhz hercules clones. Why did they had to change from 16.257Mhz ? I'll see if I can fix it digitally. Otherwise they will work but with jitter. I have a Tarmack 16Mhz in the mail.

Do you mean kHz instead of MHz? MDA/Hercules video is 18.43 kHz horizontal and 50 Hz vertical.

SpidersWeb
October 3rd, 2017, 10:20 AM
Do you mean kHz instead of MHz? MDA/Hercules video is 18.43 kHz horizontal and 50 Hz vertical.

It's the pixel clock.

See Scali's thread here: http://www.vcfed.org/forum/showthread.php?52284-MDA-Hercules-and-other-clones-what-s-the-frequency-Kenneth

Retro Canada
October 3rd, 2017, 10:55 PM
Here got my Taramack Hercules 16Mhz:

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

Scali
October 4th, 2017, 02:55 AM
My main concern is about the stupid 16Mhz hercules clones. Why did they had to change from 16.257Mhz ?

I have an original Hercules GB102 card, and it is 16.000 MHz as well.
So Hercules clones that run 16.000 MHz, are actually correct Hercules clones. It's just that Hercules itself did not clone the MDA perfectly (which is 16.257 MHz).

I have two theories why Hercules used a different crystal:
1) Perhaps the 16.000 MHz ones were just cheaper, and the designer didn't think it'd make a difference
2) As noted, graphics mode runs at a slightly higher refresh rate than text mode. Perhaps the slightly slower crystal was chosen to balance this out a bit.

Retro Canada
October 4th, 2017, 05:37 AM
I have an original Hercules GB102 card, and it is 16.000 MHz as well.
So Hercules clones that run 16.000 MHz, are actually correct Hercules clones. It's just that Hercules itself did not clone the MDA perfectly (which is 16.257 MHz).

I have two theories why Hercules used a different crystal:
1) Perhaps the 16.000 MHz ones were just cheaper, and the designer didn't think it'd make a difference
2) As noted, graphics mode runs at a slightly higher refresh rate than text mode. Perhaps the slightly slower crystal was chosen to balance this out a bit.

My bet is on aspect ratio. Being 16Mhz the image will look a little stretched compared to 16.257. If you have a 5150 try drawing a circle on it.

Retro Canada
October 6th, 2017, 07:55 AM
Hercules now is pixel perfecft :D

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

The project will go live somewhere in the weekend. I'll publish the gerber files, FPGA code and instructions. Stay tuned. You will need the CoreEP4CE6 FPGA board, USB-Blaster (to program it) and my daughter board to plug in.

You can start ahead and order the FPGA development board:

http://www.ebay.ca/itm/ALTERA-FPGA-EP4CE6-EP4CE6E22C8N-Cyclone-IV-Development-Evaluation-Board-Core-Kit-/251194080650?hash=item3a7c557d8a:m:ml4dTj6aYOvUGNx Uk3wLEOQ

Scali
October 6th, 2017, 08:29 AM
Hercules now is pixel perfecft :D

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

Looks great!

Retro Canada
October 8th, 2017, 11:26 AM
Who wanted borders ? I have normalized all the 3 outputs to 720x400. It turns out my monitor does not like 640x400, it does but with bad scaling. 720x400 by the other hand it does pretty well (because that is VGA text mode). Also when changing resolutions the monitor may get the previous settings for the other format and make the screen disaligned. With this change we loose some real state but we display borders and overscan. There is a button to adjust the screen horizontal and vertically.

https://youtu.be/MbJrrwkA2q0

Plasma
October 8th, 2017, 01:20 PM
Can you adjust horizontal width? The aspect ratio looks wrong in the video.

SpidersWeb
October 8th, 2017, 03:36 PM
Can you adjust horizontal width? The aspect ratio looks wrong in the video.
That's to be expected, as you can't stretch 320 to 720, only 640 (can't draw quarter of a pixel sadly), but I guess could adjust it on your display when using it, or edit captured video after the fact.

It may however look better on 16:9 display? Might be an added bonus?

Plasma
October 8th, 2017, 03:43 PM
Sure you can. Interpolation.

Personally I'd rather have 640x400 with the color border in the actual overscan, not as part of the image. But whatever.

SpidersWeb
October 8th, 2017, 04:43 PM
Sure you can. Interpolation.

Personally I'd rather have 640x400 with the color border in the actual overscan, not as part of the image. But whatever.

True. If that's plausible for a Cyclone IV then that could be a useful addition. It's just not something I expected.
640x400 with borders in overscan would be my preference also.

Retro Canada
October 8th, 2017, 09:03 PM
Sure you can. Interpolation.

Personally I'd rather have 640x400 with the color border in the actual overscan, not as part of the image. But whatever.

I just changed from 640x400 to 720x400 for you to ask me to do interpolation now to look like it was 640x400 ? :P

Anyway interpolation is easy for the width, but harder for the height. This is because several rows should be stored and fetched at the same time. For the horizontal, you just keep the previous pixels in a circular buffer...

But the low color depth (3-bit) and low resolution will not make it look great, better use your monitor scaling by changing the resolution

Plasma
October 8th, 2017, 10:00 PM
Hey I didn't ask for you to change it to 720 :P or even request borders for that matter...was simply pointing out VGA supported color borders in the overscan. I think it's great how it was. :)

Retro Canada
October 9th, 2017, 10:44 AM
Hey I didn't ask for you to change it to 720 :P or even request borders for that matter...was simply pointing out VGA supported color borders in the overscan. I think it's great how it was. :)

Haha not you, someone else here asked for overscan. The problem with the lack of overscan is every game or app that change the CRTC settings will move the image out of the visible area and you have to adjust it again. There is no standard for front/back porch and the monitors displayed the overscan so it wasn't a big deal.

VGA video modes by other hand has standard front/porch values

Casey
October 14th, 2017, 03:45 PM
I have a Herc clone card. Is there a simple way I can tell what the frequency is? It works with my 5151 monitor, but I have no instruments.

...Which reminds me -having no instruments- would be a decent multimeter (vice ohmmeter) be a good investment? I used to have one, but it got tossed in the hospital move as well. If so, what's decent these days? IIRC I got mine at the local Radio Shack, now closed, a long time ago. Can I get a decent one at Walmart or Harbor Freight for less than $20?

Retro Canada
October 14th, 2017, 05:51 PM
I have a Herc clone card. Is there a simple way I can tell what the frequency is? It works with my 5151 monitor, but I have no instruments.

...Which reminds me -having no instruments- would be a decent multimeter (vice ohmmeter) be a good investment? I used to have one, but it got tossed in the hospital move as well. If so, what's decent these days? IIRC I got mine at the local Radio Shack, now closed, a long time ago. Can I get a decent one at Walmart or Harbor Freight for less than $20?

Just look at your card, there is an oscillator (a little tin-can), mine says: 16.000 so that's it, 16Mhz. These cards get the clock direct from the oscillator, no PLLs.

A multimeter is only useful for voltages, resistance, continuity test but not for frequency. To measure frequency you need a oscilloscope.

Retro Canada
October 14th, 2017, 05:53 PM
look this one: http://www.vgamuseum.info/media/k2/items/cache/6a3568ec75354456ab1e6b6fc1540ba0_XL.jpg

the oscillator is on the left corner A.I.G. 16.000

8008guy
November 16th, 2017, 07:40 PM
Hi Retro C.

How is the project comming along?

Retro Canada
November 17th, 2017, 09:28 AM
Well I have published it month ago:

https://sites.google.com/site/tandycocoloco/mda-cga-ega-to-vga

ibmapc
November 17th, 2017, 11:01 AM
If someone has some boards made and puts some kits together, I would surely buy at least two un-assembled kits!!

Plasma
November 17th, 2017, 06:04 PM
I'm interested in at least 3 or 4 boards...I might have to figure out how to order them myself.

ibmapc
November 17th, 2017, 06:31 PM
I'm interested in at least 3 or 4 boards...I might have to figure out how to order them myself.

If there is enough interest in this, it would be great to do this as a group. I would be willing to commit to and pay for up to three boards and parts kits in advance. What we need here is someone with experience to spearhead the whole thing. Unfortunately, I don't have the knowledge to do this on my own, but would be willing to help in some small capacity with guidance from someone more experienced than myself with these kind of projects. Perhaps we should start a new thread for this to gauge interest.

8008guy
November 17th, 2017, 07:31 PM
I would like two pcb's

Len

JoJo_ReloadeD
November 20th, 2017, 03:25 AM
First of all I would like to thank you @Retro Canada for making this wonderful adapter, just assembled it and works flawlessly :D

In any case I have noticed two things:

- In hercules / mda mode the screen is missing like 100 pixels from the left side, is this normal?
- In cga mode, depending on the cga card I use I'm getting those interferences on the screen: (look for the pattern where the ninja is standing)


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

It depends on the cga I'm using. One has no interference at all, one has this interference, and others have a lot...

What can be causing it?

Retro Canada
November 20th, 2017, 09:08 AM
Presse the RESET button several times (the button on the top of the FGPA unit) this is a fine tunning adjustment keep pressing and it will wrap up at the orignal position at some point.

For the MDA which card are you using ?

Retro Canada
November 20th, 2017, 09:12 AM
Ah, if screen goes up (or down) flip the dip switch 1 (the closed to the edge of the board) this change between hor/vert adjust (also a led you turn on/off)

The adjust is needed becase some video cards use different timings, that is the distance between the hsync pulse and the first pixel is variable and this is a digital design with low resolution capture, if it hits the pixel borderline you see these fluctuations. But pressing reset moves the digitize center.