Electron graphics card

discuss both original and modern hardware for the bbc micro/electron
Post Reply
Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Electron graphics card

Post by Ramtop » Mon Apr 27, 2020 6:09 pm

Hi all,

I waffled a bit about this on twitter, so now I’ve got to stop being lazy and write a post with some actual detail. Since about the middle of last year I’ve been working on and off on a new piece of hardware for my Electrons. Due to an abundance of lockdown enforced spare time I’ve gotten it somewhat functional now, so I thought I’d say a bit about it.

Firstly, to be clear, this design still only in prototype form. It is mostly a proof of concept built for my own use, and isn’t intended to be an actual product. Elements of the design will probably show up in something commercial at some point in the future, though.

With that said, here’s a look at the imaginatively named ElkVGA.
elkvga_1.jpg
attached to a VGA CRT:
elkvga_2.jpg
As the name suggests it is primarily a graphics card. It’s based on an Altera/Intel Max 10 FPGA, plugs into the Electron’s expansion connector and in the current hardware revision has:

- A fast SD card interface using a custom SPI controller and MMFS driver
- 512K of SRAM
- 64K of sideways ROM flash storage
- an SPI port capable of running up to 25MHz
- and a 15-pin socket for a VGA monitor

The main thing is the VGA output, of course. It provides a display that appears similar to the normal RGB output but is suitable to be fed directly into a VGA monitor (technically it is 800x600 60Hz with the Elk video in a 640x512 central area).

The VGA output is entirely separate from the ULA, it snoops the 6502 bus for writes to the screen memory and display registers. A duplicate of the Electron’s screen is held in the FPGA’s block RAM and scaled to fit in the 640x512 display area on the VGA output. The scaling is purely integer so no fuzziness is introduced. All seven screen modes are supported.

An obvious enhancement to do is 16 real colours in mode 2, so that ability is provided. The colour palette is increased to 12-bit / 4096 colours (chosen because that’s what the VideoNuLA uses). Up to 32 sixteen-colour palettes can be defined and each line of the display can be allocated one of them, giving a maximum of 512 colours on-screen. After the initial setup no CPU intervention is needed for this to work.

Here's a slightly fuzzy picture of 16 real colours combined with a palette split in mode 2:
32col.jpg
and a palette split used to change the control panel in Thrust:
thrust_cp.jpg
Because of the 800x600 resolution there is a visible border around the screen area, which can be (presently) set to any of 64 colours. The blank scan lines in modes 3 and 6 take the colour of the border. There’s also a scan-line emulation mode which blanks alternate lines in the 640x512 screen area, this actually makes a VGA CRT look much more like a 15KHz screen than I expected. It can be toggled via a keyboard short-cut.

Border colour and mode 6 blank lines changed to red:
vdu.jpg
The latest thing I’ve added is a screen-mode lock, as way of forcing the CPU to 1MHz when displaying slow screen modes. Because the VGA output doesn’t depend on the ULA it’s possible to put the system into a slow screen mode, like mode 2, lock the VGA output to that mode, and then poke the ULA directly to put it into a fast mode. That results in the ElkVGA running in mode 2, but with the ULA driving the CPU at 1MHz. I’ve only played with this briefly, there may be hidden gremlins here, but it seems to work quite nicely so far and the extra speed is easily apparent.

The advantages of bolting a on a new video system are obvious, but there is a fairly sizeable drawback though: compatibility. The ElkVGA is using completely different timings from the ULA so any games that play timing tricks, like changing the palette or screen mode mid-frame, are not going to work well if at all. From the testing I’ve done actually about 80% of games play fine, the ones that don’t are mainly ones changing palette mid-frame to hide data in screen memory (games like Joe Blade and Barbarian for example).

I’ll post more details later, if anyone’s interested.

(sorry for not having much in the way of cool demo pictures, I haven’t written anything to show off the hardware other than the rather basic mode 2 colour blocks thingy)
Gary

User avatar
egel
Posts: 83
Joined: Mon Nov 25, 2019 1:10 pm
Location: Almere, Flevoland, The Netherlands
Contact:

Re: Electron graphics card

Post by egel » Mon Apr 27, 2020 6:18 pm

Looks very nice, but why VGA and not HDMI? You probably have a good reason for it, but which?

Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Re: Electron graphics card

Post by Ramtop » Mon Apr 27, 2020 6:43 pm

Multiple reasons. For retro machines I think CRTs are impossible to beat as a display, but 15Khz RGB CRTs are getting rare now. Good quality VGA CRTs are still common, though, and all the CRTs I have personally are VGAs. So VGA output made sense. And almost all LCD screens still have a VGA input anyway.

There's a chance the VGA core of the ElkVGA will find its way into a commercial product, which rules out HDMI because I would have to pay the ridiculous licensing fees the HDMI association charges.
Gary

User avatar
davidb
Posts: 2760
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron graphics card

Post by davidb » Mon Apr 27, 2020 8:23 pm

Looks good! :) Some of us have been discussing this kind of enhancement for a while, so it's good to see someone experimenting with a solution.

One enhancement that would be interesting is to define a palette for each scanline in the page just below the screen start. I used two pages of memory for my palette experiments, though maybe you wouldn't want to reuse the ULA's palette formats.

Anyway, keep it up! This looks like fun. :)

User avatar
0xC0DE
Posts: 575
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Electron graphics card

Post by 0xC0DE » Mon Apr 27, 2020 10:21 pm

As commented on Twitter, I am following this with great interest and hope one day it will find its way into a commercial product! Well done!
0xC0DE
:idea: Follow me on Twitter :idea: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
davidb
Posts: 2760
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron graphics card

Post by davidb » Mon Apr 27, 2020 10:25 pm

Ramtop wrote:
Mon Apr 27, 2020 6:09 pm
The latest thing I’ve added is a screen-mode lock, as way of forcing the CPU to 1MHz when displaying slow screen modes. Because the VGA output doesn’t depend on the ULA it’s possible to put the system into a slow screen mode, like mode 2, lock the VGA output to that mode, and then poke the ULA directly to put it into a fast mode. That results in the ElkVGA running in mode 2, but with the ULA driving the CPU at 1MHz. I’ve only played with this briefly, there may be hidden gremlins here, but it seems to work quite nicely so far and the extra speed is easily apparent.
You could try some BBC Micro games that run slowly on the Electron to see if they run closer to original speed. Some of the early Superior games, like Wallaby, for example.

User avatar
jgharston
Posts: 4001
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Electron graphics card

Post by jgharston » Tue Apr 28, 2020 12:42 am

If you post the hardware I/O details to control the deep palette, it would be a useful addition to the PCHANGE palette selector program.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Re: Electron graphics card

Post by Ramtop » Tue Apr 28, 2020 12:00 pm

davidb wrote:
Mon Apr 27, 2020 8:23 pm
One enhancement that would be interesting is to define a palette for each scanline in the page just below the screen start. I used two pages of memory for my palette experiments, though maybe you wouldn't want to reuse the ULA's palette formats.
The big limitation I have to deal with is that VGA output requires constant access to palette information, and the electron has no DMA ability so the FPGA can't fetch data from main memory at will, all it can do is monitor accesses made by the 6502. The only real way I could see of storing palette data in the elk's memory would be to snoop the initial write of the data and keep a copy in block RAM for the VGA output to access. Which does seem a little like pointless duplication! :D

I did play with the idea of having a pseudo sideways-RAM bank dedicated to palette data, but that's difficult to manipulate from BASIC. May still do it in the future.

At present all palette and assignment data is stored in FPGA block RAM, accessed via five registers. Definitions for individual colours are done similarly to the VideoNuLA, first byte is [index:R] second is [G:B]. But I use two separate registers, rather than the VideoNuLA's double-write. Registers 3 and 4 are the palette split regs, the first takes a scan line number (0-255) and the second the palette number (0-31) to be used on that line. Final register selects the palette to be modified by the colour definition registers.
jgharston wrote:
Tue Apr 28, 2020 12:42 am
If you post the hardware I/O details to control the deep palette, it would be a useful addition to the PCHANGE palette selector program.
I'll post the details as soon as I stop messing about with stuff! :D

At present I'm not even sure the 12-bit palette will be retained in the next revision of the board. The similarity with the VideoNuLA is valuable, but I still think 12-bit is overkill and 8-bit would probably be fine and would free up some valuable I/O pins and block RAM.
Gary

Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Re: Electron graphics card

Post by Ramtop » Tue Apr 28, 2020 12:02 pm

I spent the morning porting over some of the images from the Bitshifter's VideoNuLA slideshow disk, which look pleasingly colourful.
Attachments
flash.jpg
chess.jpg
tiger.jpg
Gary

User avatar
davidb
Posts: 2760
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron graphics card

Post by davidb » Tue Apr 28, 2020 1:44 pm

Ramtop wrote:
Tue Apr 28, 2020 12:00 pm
The big limitation I have to deal with is that VGA output requires constant access to palette information, and the electron has no DMA ability so the FPGA can't fetch data from main memory at will, all it can do is monitor accesses made by the 6502. The only real way I could see of storing palette data in the elk's memory would be to snoop the initial write of the data and keep a copy in block RAM for the VGA output to access. Which does seem a little like pointless duplication! :D
That's what I thought you might have to do.
Ramtop wrote:
Tue Apr 28, 2020 12:00 pm
I did play with the idea of having a pseudo sideways-RAM bank dedicated to palette data, but that's difficult to manipulate from BASIC. May still do it in the future.
Well, if you provided palette registers somewhere up above &8000, probably above &FC00, then software could be written to manipulate these on each scanline, so it's not something the hardware would need to take care of.

Some other thoughts:
  • Would it be possible to add MODE 7 support, perhaps by reimplementing the teletext display hardware of the BBC Micro in FPGA logic? This would require additional software support, of course.
  • Could this be used to implement more fine-grained scrolling?
  • Have you thought about implementing enhancements to the sound system, or providing other "virtual" peripherals?
I'm sure you have your own list of additions and improvements. :)

User avatar
Arcadian
Site Admin
Posts: 3331
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Electron graphics card

Post by Arcadian » Tue Apr 28, 2020 1:50 pm

Goodness, what a wonderful project - count me in for one if they become available please!

Could you feature both VGA and HDMI outputs?

Btw, would you be up for popping into this Saturday's "Virtual" ABug conference on Zoom to give a demo and overview of how it works?
viewtopic.php?f=25&t=19156
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Re: Electron graphics card

Post by Ramtop » Tue Apr 28, 2020 3:28 pm

davidb wrote:
Tue Apr 28, 2020 1:44 pm
Well, if you provided palette registers somewhere up above &8000, probably above &FC00, then software could be written to manipulate these on each scanline, so it's not something the hardware would need to take care of.
The current palette registers are located at &FCxx, so they can be fairly easily accessed. Nothing to stop manual CPU-driven palette swaps either, but the hardware does that so much better.

On the other things, I suppose I should clarify what possible features are likely to happen.

- Mode 7; unlikely, but I'm not ruling it out. Need to experiment a bit and see how much time it would take to implement.
- Hardware scrolling, quite possible. It's not hard to do.
- Sprites. Again, not hard to do but quite hungry for block RAM. They do also seem a bit 'un-Acorn' to me, I'm very keen for the ElkVGA to feel like an electron but as it would have been if the ULA wasn't so limited.
- Audio. I'd love to do this, but haven't even looked at it yet. An off the shelf audio CODEC on the SPI port sounds like a quick way to do it.
- Joystick port; likely if I can free up enough I/Os for it.
- Advanced screen modes; if I forget about things like sprites then there should be enough block RAM to do some kind of extended screen modes. Not sure of what form these would take, though.

The big problem is always lack of block RAM. The FPGA I'm using (Intel 10M08) only has 42K of it and costs £25 a pop. Bigger variants have more, but the cost escalates into silly money very quickly and they have a different pin-out so a board re-design would be necessary (thanks Intel! :( )

Arcadian wrote:
Tue Apr 28, 2020 1:50 pm
Could you feature both VGA and HDMI outputs?

Btw, would you be up for popping into this Saturday's "Virtual" ABug conference on Zoom to give a demo and overview of how it works?
viewtopic.php?f=25&t=19156
No go for HDMI, I'm afraid. The legal issues surrounding use of that standard are unpleasant. Put me down as a 'possible' for ABug, please. I'm scheduled for remote work stuff on Saturday, but that may still not happen. Either way, I'll try and post a video showing the ElkVGA and some no doubt scintillating commentary :lol:
Gary

User avatar
jgharston
Posts: 4001
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Electron graphics card

Post by jgharston » Tue Apr 28, 2020 3:34 pm

davidb wrote:
Tue Apr 28, 2020 1:44 pm
Well, if you provided palette registers somewhere up above &8000, probably above &FC00, then software could be written to manipulate these on each scanline, so it's not something the hardware would need to take care of.
Is your hardware able to "see" &FExx? If so, the simplest thing to do is replicate the vNuLA registers, ignoring low colour bits that you don't implement. If not, then best to replicate pre-existing registers in the &FCxx space.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
egel
Posts: 83
Joined: Mon Nov 25, 2019 1:10 pm
Location: Almere, Flevoland, The Netherlands
Contact:

Re: Electron graphics card

Post by egel » Tue Apr 28, 2020 3:44 pm

Ramtop wrote:
Mon Apr 27, 2020 6:43 pm
There's a chance the VGA core of the ElkVGA will find its way into a commercial product, which rules out HDMI because I would have to pay the ridiculous licensing fees the HDMI association charges.
Comes DVI also with ridiculous licensing fees? DVI-I would make it compatible with both VGA and HDMI. The market would probably be larger if it could also directly provide digital signal.

User avatar
Arcadian
Site Admin
Posts: 3331
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Electron graphics card

Post by Arcadian » Tue Apr 28, 2020 3:48 pm

Ramtop wrote: No go for HDMI, I'm afraid. The legal issues surrounding use of that standard are unpleasant. Put me down as a 'possible' for ABug, please. I'm scheduled for remote work stuff on Saturday, but that may still not happen. Either way, I'll try and post a video showing the ElkVGA and some no doubt scintillating commentary :lol:
Ah I see, ok no prob - I'm fine with VGA personally - have still got a few old Acorn CRTs with VGA.

Regarding the Zoom meeting on Sat, do you want to pop your name in the thread as a maybe, then sydney (Simon) will PM you the meeting logins once they're confirmed. viewtopic.php?f=25&t=19156
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

Ramtop
Posts: 223
Joined: Tue Oct 23, 2018 1:40 pm
Contact:

Re: Electron graphics card

Post by Ramtop » Tue Apr 28, 2020 7:10 pm

egel wrote:
Tue Apr 28, 2020 3:44 pm
Comes DVI also with ridiculous licensing fees? DVI-I would make it compatible with both VGA and HDMI. The market would probably be larger if it could also directly provide digital signal.
DVI is free to use as I understand it. But there are two issues; generating both analogue and digital outputs at the same time add a major amount of complexity that I'm not sure I want to deal with. And second, there are no free I/O pins on the FPGA. I couldn't add DVI without removing VGA, and even then I'm not sure there would be enough pins.
Gary

User avatar
uniforix
Posts: 59
Joined: Sun Apr 21, 2013 10:57 pm
Contact:

Re: Electron graphics card

Post by uniforix » Tue Apr 28, 2020 10:31 pm

=D>

mind blown again, ramtop keeps on giving.

definitely be down for one of these if you get to selling!

keep up the awesome work :D
---

Electron Forever
www.electronforever.co.uk

Dan1975
Posts: 12
Joined: Fri Oct 19, 2018 12:55 am
Contact:

Re: Electron graphics card

Post by Dan1975 » Fri May 01, 2020 6:21 pm

Wow this sounds awesome :D

User avatar
Lardo Boffin
Posts: 2056
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Electron graphics card

Post by Lardo Boffin » Fri May 01, 2020 7:49 pm

More amazing stuff! Count me in if they are ever for sale.
Atom, issue 5
Elk
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

Post Reply

Return to “8-bit acorn hardware”