Palettemate / enhanced video ULA with 4096 colours

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Wed Nov 16, 2016 6:57 pm

I've mentioned the Wild Vision Palettemate on here before - it came out in 1986 and gave the Beeb a palette of 4096 colours and 16 proper colours (i.e. non-flashing) in mode 2.

I've been on the look out for one for ages but haven't been able to find one. I even tried contacting Pete Wild but to no avail. Finally, I decided to bite the bullet, learn a bit of VHDL and make one myself...

I've re-implemented the Beeb's video ULA in an Altera MAX II CPLD but have added extra functionality to manage the 12-bit palette and give 16 colours in modes 2 and 8.

It's very much a prototype at the moment as I'm using a MAX II development board connected to some stripboard that is sitting in my Master. However, it's more or less working :D

20161116_182723.jpg

20161116_183519.jpg


The first picture shows mode 2 displaying 16 shades of grey and the second shows the Beeb's original 8 colours alongside their half-intensity equivalents. The picture quality isn't great as I just grabbed them on a mobile but they look better on the screen.

It still has the odd issue in mode 7 but I think that may be due to the duty-cycles of some of the generated clocks being off a bit.

User avatar
hoglet
Posts: 6271
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Palettemate / enhanced video ULA with 4096 colours

Postby hoglet » Wed Nov 16, 2016 7:03 pm

RobC wrote:It's very much a prototype at the moment as I'm using a MAX II development board connected to some stripboard that is sitting in my Master. However, it's more or less working :D

This is excellent.

It would be great to see a picture of the prototype.
RobC wrote:It still has the odd issue in mode 7 but I think that may be due to the duty-cycles of some of the generated clocks being off a bit.

In Mode 7 the pixel clock is effectively 12MHz (cf 16MHz in the other modes). If you do accidentally resample it at 16MHz it introduces all sorts of strange artefacts.

Dave

User avatar
sirmorris
Posts: 701
Joined: Wed Feb 11, 2009 12:18 pm
Location: oxfordshire uk
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby sirmorris » Wed Nov 16, 2016 7:15 pm

:shock: =D> =D> =D>

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Wed Nov 16, 2016 7:57 pm

Here's a picture of the board - it's not much to look at! There are lots of redundant components as I did lots of "experimenting" :oops:
20161116_193253.jpg


hoglet wrote:In Mode 7 the pixel clock is effectively 12MHz (cf 16MHz in the other modes). If you do accidentally resample it at 16MHz it introduces all sorts of strange artefacts.

Yeah - I am sampling at 16MHz at the moment but I've got a 48MHz oscillator (and a 96MHz one) on order. Mode 7 works most of the time (with a bit of shimmering) but there's the odd glitch where the display goes white. As I said, the duty-cycles of my 4 & 8MHz clocks look a little off and I'm wondering if this is messing up the teletext clock?

User avatar
simonm
Posts: 162
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby simonm » Wed Nov 16, 2016 8:19 pm

Holy moly this is amazing!!! :)


User avatar
Lardo Boffin
Posts: 552
Joined: Thu Aug 06, 2015 6:47 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby Lardo Boffin » Wed Nov 16, 2016 8:57 pm

When can I buy one of these? Awesome!
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, matchbox co-proc, Viglen twin 40/80 5.25" discs, acorn cassette
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc, Acorn 6502 coproc

jregel
Posts: 56
Joined: Fri Dec 20, 2013 6:39 pm
Location: Gloucestershire

Re: Palettemate / enhanced video ULA with 4096 colours

Postby jregel » Wed Nov 16, 2016 9:50 pm

Very impressive! It'll be interesting to see how far you can take this!

User avatar
jms2
Posts: 1791
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Palettemate / enhanced video ULA with 4096 colours

Postby jms2 » Wed Nov 16, 2016 10:08 pm

As everyone else said... this is amazing! =D> =D> =D> =D>

How does it work (specifically, how does it deliver its improved output within the constraints of the original BBC system)? And how did you manage to reverse engineer something that, er, doesn't exist? :?

steve3000
Posts: 1669
Joined: Sun Nov 25, 2012 12:43 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby steve3000 » Wed Nov 16, 2016 10:14 pm

Great work Rob, this is excellent!

RobC wrote:I've mentioned the Wild Vision Palettemate on here before - it came out in 1986 and gave the Beeb a palette of 4096 colours and 16 proper colours (i.e. non-flashing) in mode 2.

I remember reading about this BITD (probably in The Micro User) and imagining how amazing it would be to have one...

User avatar
jgharston
Posts: 2591
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Palettemate / enhanced video ULA with 4096 colours

Postby jgharston » Wed Nov 16, 2016 10:24 pm

Lardo Boffin wrote:When can I buy one of these? Awesome!
You can make a close equivalent: mdfs.net/Info/Comp/BBC/Display/chameleon.gif.

RobC wrote:I've mentioned the Wild Vision Palettemate on here before - it came out in 1986 and gave the Beeb a palette of 4096 colours and 16 proper colours (i.e. non-flashing) in mode 2.
I've been trying to track one of these down to document the I/O control. The above mentioned Chameleon is controlled via the user port, but if you have something that plugs in the video ULA socket and a couple of flying leads then you can control it through the video ULA address range at &FE20-&FE23. That's how I access my border colour module, a flying lead picks up A1 and &FE22 selects the border colour.

I wrote most of a VDU extension to implement VDU 19,l,x,red,green,blue to program the palette. I'll probably find the code when looking for something else.

A few months ago somebody posted the documentation for the PRISMA video system which meant that I was finally able to fill in a big gap in the OSWORD documentation. That also has a 4096-colour palette.

Code: Select all

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

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Thu Nov 17, 2016 8:02 am

Thanks for all the encouragement everyone.

jms2 wrote:How does it work (specifically, how does it deliver its improved output within the constraints of the original BBC system)? And how did you manage to reverse engineer something that, er, doesn't exist? :?

There's a good description of how the ULA works on BeebWiki and I cleared up the rest by investigation. Others have implemented the Beeb and Elk in FPGAs so I'm by no means the first to do this.

In terms of operation, it's heavily based on the Chameleon that JGH mentioned - I built one of these a few years ago but it doesn't give the full 16 colours in mode 2.

Essentially, I have a couple of octal level shifters to convert the 5V inputs to the video ULA to 3.3V and these then feed into the EPM570 development board. I started by trying to mimic the clock generation - the socket at the top of the board originally held the VIDPROC chip and I just disabled the VIDPROC a section at a time as the EPM570 functionality replaced it.

The EPM570 mimics the video ULA but also has an additional 8-bit register (located at FE23) which controls the 12-bit palette. (The blue fly lead connected to the internal TUBE connector is picking up A1.)

An initial write to FE23 sets which of the 16 colours is to be changed (top 4 bits) and the red component (bottom 4 bits). The next write to FE23 sets the green and blue components.

The usual RGB outputs from the video ULA (plus the flashing bit in modes 2 and 8 ) are then used to index the 16 locations of the 12-bit palette. The 12 digital outputs then go through a resistor ladder DAC to produce analogue red, green and blue outputs. Originally, I fed these into some transistors and took the outputs to a separate DIN socket as the Chameleon does. I then happened to look at the Master schematic and realised that I could just take the analogue RGB and feed it directly back into the ULA outputs - this works for the RGB output socket but I don't think it'll work on the UHF and component outputs.

jgharston wrote:You can make a close equivalent: mdfs.net/Info/Comp/BBC/Display/chameleon.gif.

RobC wrote:I've mentioned the Wild Vision Palettemate on here before - it came out in 1986 and gave the Beeb a palette of 4096 colours and 16 proper colours (i.e. non-flashing) in mode 2.
I've been trying to track one of these down to document the I/O control. The above mentioned Chameleon is controlled via the user port, but if you have something that plugs in the video ULA socket and a couple of flying leads then you can control it through the video ULA address range at &FE20-&FE23. That's how I access my border colour module, a flying lead picks up A1 and &FE22 selects the border colour.

I wrote most of a VDU extension to implement VDU 19,l,x,red,green,blue to program the palette. I'll probably find the code when looking for something else.

A few months ago somebody posted the documentation for the PRISMA video system which meant that I was finally able to fill in a big gap in the OSWORD documentation. That also has a 4096-colour palette.

The Chameleon works well but I wanted 16 colours in mode 2 so that was my real motivation.(If anyone does want to build a Chameleon, I can point you at a supplier for some of the hard to obtain chips.)

I consulted your very useful memory map document before choosing FE23. I've used about 80% of the EPM570 so I hope to be able to add border control at FE22 to mimic your module.

The VDU 19 extension code would be very much appreciated as that's on my TODO list!

User avatar
danielj
Posts: 5031
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Palettemate / enhanced video ULA with 4096 colours

Postby danielj » Thu Nov 17, 2016 8:04 am

=D> Great work :D

d.

User avatar
tricky
Posts: 1774
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby tricky » Thu Nov 17, 2016 1:13 pm

I'm not familiar with this part of the hardware.
Does this completely bypass the existing palette?
If not, how does it interact with "some nasty effects"?
Is there any way to detect it in software?

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Thu Nov 17, 2016 1:33 pm

tricky wrote:I'm not familiar with this part of the hardware.Does this completely bypass the existing palette?If not, how does it interact with "some nasty effects"?Is there any way to detect it in software?

It exactly mimics the existing hardware (or attempts to) until the enhanced palette is accessed. So, at start-up it should behave as a normal Beeb (i.e. physical colour 1 is red, 8 is flashing black/white etc.).

Only when the enhanced palette is redefined does it behave differently. At this point, physical colours are chosen from the 12-bit palette and colours 8-15 no longer flash. (I am thinking about using one of the unused cursor options to toggle the flashing behaviour.)

Logical colours are still redefined using VDU 19, writes to FE21 etc.

I haven't tried it with nasty effects (or Astroblaster) yet but the principle of defining all four palette entries in modes 1 and 5 (at FE21) remains. It's just that the physical output colours can now be chosen from the palette of 4096. (I'm aware from the discussion we had at the London show that some Beebs "shimmer" when the palette entries differ so I'll have to see what happens...)

Hardware detection is difficult because the video ULA/VIDPROC is write-only. I'd like to write a ROM to allow VDU 19 etc. to control the enhanced palette and then it would be possible to detect the software.

User avatar
jgharston
Posts: 2591
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Palettemate / enhanced video ULA with 4096 colours

Postby jgharston » Thu Nov 17, 2016 1:37 pm

RobC wrote:I hope to be able to add border control at FE22 to mimic your module.
:D :D :D
Have you any thoughts on 24-bit border colour and the hardware API?

tricky wrote:Is there any way to detect it in software?
The video ULA is a write-only device. When reading from &FE20-23 on the Master series you actually end up reading "through" into screen memory. If there was a way for the new hardware to detect a read it could respond in a way that makes its presence detectable.

Code: Select all

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

atcurtis
Posts: 33
Joined: Fri Apr 08, 2016 9:47 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby atcurtis » Thu Nov 17, 2016 1:42 pm

It would take up a small amount of memory in your fpga and will be a bit tricky to remember the previous line but what about sacrificing a bit of vertical resolution in mode 2 to get a 160x128 256 colour mode?

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Thu Nov 17, 2016 2:58 pm

jgharston wrote:Have you any thoughts on 24-bit border colour and the hardware API?

Although possible, I decided against 24-bit colour because it seems like overkill when you'd only be able to display a millionth of the palette on screen at any one time. I've had a brief look at how BBC Basic for Windows and PRISMA 3 extended VDU 19 but didn't reach a conclusion. My focus so far has been on getting the hardware up and running so any thoughts are welcome.

EDIT: I now suspect you meant the hardware access method. I was thinking about keeping it in line with the rest of the palette - first write to FE22 sets the red component and the second sets the green and blue.

jgharston wrote:If there was a way for the new hardware to detect a read it could respond in a way that makes its presence detectable.

This would mean adding a R/~W input and that would mean adding another batch of level shifters as I'm already using all 16. It's doable but I would question the value - if you write to FE23 and the hardware is there, it works. If it's not there, you get usual Beeb behaviour.

atcurtis wrote:It would take up a small amount of memory in your fpga and will be a bit tricky to remember the previous line but what about sacrificing a bit of vertical resolution in mode 2 to get a 160x128 256 colour mode?

How would you see this working? Would the idea be to read a byte at a time, do the look-up on the palette and then output half a line (80 pixels) and then do the same for the other half?

I've not really thought about it but I'm not sure how this would interact with the CRTC (e.g. hsync). If anyone has any thoughts then I'm open to suggestions. However, I'm only using a CPLD and it's about 80% full at the moment.

I know that the Enterprise did a 256 colour equivalent of mode 8 (i.e. 80 x 256 resolution) - I've briefly thought about implementing something like that but concentrated on the original goal of recreating the PaletteMate first.

User avatar
tricky
Posts: 1774
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby tricky » Thu Nov 17, 2016 4:52 pm

Phoenix uses palette partial programming, not AstroBlaster ;)
128x128 in 16 or 15+16 colours would be very interesting if you did support scan lines doubling.
The 15+16 would work by using the first colour if it was not 0, but if it was, then you would use the second. This would simulate the 3+4 colour palette trick in mode 2 to have sprites(3 cols) and background(4 cols).

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Thu Nov 17, 2016 5:24 pm

tricky wrote:Phoenix uses palette partial programming, not AstroBlaster ;)

Sorry - I should have checked before posting! :oops:

tricky wrote:128x128 in 16 or 15+16 colours would be very interesting if you did support scan lines doubling.
The 15+16 would work by using the first colour if it was not 0, but if it was, then you would use the second. This would simulate the 3+4 colour palette trick in mode 2 to have sprites(3 cols) and background(4 cols).

Unfortunately, scan line doubling is beyond the CPLD I'm using as it simply doesn't have enough space :(

It might be possible to do something like this at 80 x 256 (a bit like the Enterprise) and you might even push to 96 (or even 100) x 256 with overscan.

One thing that might be possible in the remainder of the CPLD is single pixel horizontal scrolling by having a small configurable delay register. I want to focus on sorting out the border control and mode 7 issues first though.

User avatar
tricky
Posts: 1774
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby tricky » Thu Nov 17, 2016 5:52 pm

Pixel horizontal scrolling would be great, but you also need to blank one edge and stop normally, discarding the delayed pixels at the other (like the C64).
I guess you would need to blank the first 4 mode 1 pixels, delaying the originals by 0, 1, 2 or 3 pixels and then stopping when you reach the right hand side, throwing away up to 3 pixels.
Blanking the whole character allows more flexibility about when you update the "off-screen" bit.
I don't know what you do about different character width modes, e.g. 0 or "8". Basically, blank one byte/"character" and allow 0 to 7 pixel offsets.

atcurtis
Posts: 33
Joined: Fri Apr 08, 2016 9:47 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby atcurtis » Fri Nov 18, 2016 12:07 pm

RobC wrote:Unfortunately, scan line doubling is beyond the CPLD I'm using as it simply doesn't have enough space :(


What CPLD are you using and will the code be uploaded to github?

Sounds like it'd be fun to play ... I have a spare XC9572 which should be 5V compatible or a few XC9536XL if it could squeeze into that.
Unfortunately, I don't have anything in between that and a Spartan6.

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Fri Nov 18, 2016 2:59 pm

atcurtis wrote:What CPLD are you using and will the code be uploaded to github?

Sounds like it'd be fun to play ... I have a spare XC9572 which should be 5V compatible or a few XC9536XL if it could squeeze into that.
Unfortunately, I don't have anything in between that and a Spartan6.

It's an Altera Max II EPM570 and I'm currently using about 460 LEs and 41 I/O pins - the extended palette alone is 16 x 12-bits plus some extra bits to hold state information. It could be hung off the back in a RAMDAC or a 74LS612 but I still think the original ULA logic would be a tight fit for the CPLDs you mention.

Once I've got it working, I'll decide what I'm going to do with the code. I'd like to make it available but I have been stung when doing that in the past. Ideally, I'd get some PCBs made and make them available at cost but that's a little way off yet.

User avatar
kieranhj
Posts: 452
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Palettemate / enhanced video ULA with 4096 colours

Postby kieranhj » Fri Nov 18, 2016 4:15 pm

RobC wrote:Once I've got it working, I'll decide what I'm going to do with the code. I'd like to make it available but I have been stung when doing that in the past. Ideally, I'd get some PCBs made and make them available at cost but that's a little way off yet.

This is amazing work Rob, really impressive! I think there are many people, myself included, that would love to purchase an enhanced ULA board. I'm already starting to think about some of the amazing C64- beating ( \:D/ ) demos that we could write. And re-coding all the image convertors with the new palette capabilities. So many new options... =D>

atcurtis
Posts: 33
Joined: Fri Apr 08, 2016 9:47 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby atcurtis » Fri Nov 18, 2016 4:47 pm

RobC wrote:
atcurtis wrote:What CPLD are you using and will the code be uploaded to github?

Sounds like it'd be fun to play ... I have a spare XC9572 which should be 5V compatible or a few XC9536XL if it could squeeze into that.
Unfortunately, I don't have anything in between that and a Spartan6.

It's an Altera Max II EPM570 and I'm currently using about 460 LEs and 41 I/O pins - the extended palette alone is 16 x 12-bits plus some extra bits to hold state information. It could be hung off the back in a RAMDAC or a 74LS612 but I still think the original ULA logic would be a tight fit for the CPLDs you mention.

Once I've got it working, I'll decide what I'm going to do with the code. I'd like to make it available but I have been stung when doing that in the past. Ideally, I'd get some PCBs made and make them available at cost but that's a little way off yet.


I like the idea of using a RAMDAC... then a simple CPLD could provide the glue logic.
Scan line doubling would need more space - to store a scan-line worths amount of data which for the beeb is fixed at 640 bits... would probably be simpler to use an external 4040 and some SRAM and just use the CPLD as glue. May as well use a 4066 for switching in the teletext RGB. Would still need the HSYNC signal.

This does sound like fun...

User avatar
tricky
Posts: 1774
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Palettemate / enhanced video ULA with 4096 colours

Postby tricky » Fri Nov 18, 2016 5:00 pm

What is fixed at 640 bits?

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Fri Nov 18, 2016 5:00 pm

kieranhj wrote:This is amazing work Rob, really impressive! I think there are many people, myself included, that would love to purchase an enhanced ULA board. I'm already starting to think about some of the amazing C64- beating ( ) demos that we could write. And re-coding all the image convertors with the new palette capabilities. So many new options...

Thanks. Hopefully, I can sort out the mode 7 issues when the new oscillators arrive and then get on with prototyping a PCB.

Also, one of the things I'd like to do is to write a quick demo to switch the palette on every scan line - I think this should be able to display at least 2048 colours on screen at once.

atcurtis wrote:I like the idea of using a RAMDAC... then a simple CPLD could provide the glue logic.
Scan line doubling would need more space - to store a scan-line worths amount of data which for the beeb is fixed at 640 bits... would probably be simpler to use an external 4040 and some SRAM and just use the CPLD as glue. May as well use a 4066 for switching in the teletext RGB. Would still need the HSYNC signal.

This does sound like fun...

I've got a 16 x 12-bit Brooktree RAMDAC that will do the job and that was my backup plan. Once I'd got the original ULA implementation working, it was obvious that the extended palette would fit so I didn't need it.

Unfortunately, I can't remember how many LEs the original ULA used but I have a feeling it was around 170/180. I can recompile the old code to find out if you want.

My intention was always to recreate the capabilities of the Palettemate so I haven't given much thought to more functionality. Also, this is very new to me so I'm kind of learning as I go!

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Fri Nov 18, 2016 5:04 pm

tricky wrote:What is fixed at 640 bits?

Yes - good point. With overscan, it's possible to have a display that's close to 800 pixels wide in mode 0.

atcurtis
Posts: 33
Joined: Fri Apr 08, 2016 9:47 am

Re: Palettemate / enhanced video ULA with 4096 colours

Postby atcurtis » Fri Nov 18, 2016 5:08 pm

RobC wrote:Unfortunately, I can't remember how many LEs the original ULA used but I have a feeling it was around 170/180. I can recompile the old code to find out if you want.

My intention was always to recreate the capabilities of the Palettemate so I haven't given much thought to more functionality. Also, this is very new to me so I'm kind of learning as I go!


I can see a great use of just the code for reimplementing the original ULA as it can be used as a replacement source for the VIDPROC chip to keep our computers still running...
On that note, I see https://github.com/mist-devel/mist-board/blob/master/cores/bbc/rtl/vidproc.v as a maybe good starting point for playing about...

RobC
Posts: 1642
Joined: Sat Sep 01, 2007 9:41 pm

Re: Palettemate / enhanced video ULA with 4096 colours

Postby RobC » Fri Nov 18, 2016 6:37 pm

atcurtis wrote:I can see a great use of just the code for reimplementing the original ULA as it can be used as a replacement source for the VIDPROC chip to keep our computers still running...
On that note, I see https://github.com/mist-devel/mist-board/blob/master/cores/bbc/rtl/vidproc.v as a maybe good starting point for playing about...

That looks a lot cleaner than my code! Although I don't know Verilog yet - I only chose VHDL as a friend lent me a textbook on it...

I'll take a look at it as it might help me resolve some issues. (I found another one tonight - looks like an extra clock period's worth of data is being displayed at the left hand edge of the screen.)


Return to “hardware”

Who is online

Users browsing this forum: No registered users and 6 guests