Page 1 of 2

PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 6:53 pm
by Ruleset

I have made a couple of builds that add PWM on the 18-bit DAC to get 24-bit color for the cores that need it. This is for any non-scaled signals that use the VGA port on the IO board. It works by quickly alternating between two different color values to get a color in between. The PWM happens very fast so it can be done even for 640 wide images.

We have been testing it on the Mister FPGA discord, here are some pictures:
RGB SCART:

MisterN64CoreRGBPWM.jpg
MisterN64CoreRGBPWM.jpg (448.63 KiB) Viewed 22036 times

Active Y/C S-video PWM off:

sotn-svid-01-a-pwm-off.jpg
sotn-svid-01-a-pwm-off.jpg (454.81 KiB) Viewed 22036 times

Active Y/C S-video PWM on:

sotn-svid-01-b-pwm-on.jpg
sotn-svid-01-b-pwm-on.jpg (391.52 KiB) Viewed 22036 times

I have included a build for N64, PSX and Saturn, PWM is always on in these builds, no settings needed.

Here is my fork of the N64 core with the PWM changes: https://github.com/Jokippo/N64_MiSTer_PWM

It seems to work quite well and may be a good alternative to using direct video or buying a new 24-bit IO board. For now, it looks like this won't be included in the MiSTer framework.

If you want these build to be included in update_all then add these lines to downloader.ini:

Code: Select all

[Jokippo/MiSTer_PWM_Cores]
db_url = https://raw.githubusercontent.com/Jokippo/MiSTer_PWM_Cores/db/db.json.zip

A folder 'ConsolePWM' will be created with the PWM cores inside

edit: Updated N64 core to most recent source. PSX core had some red color shift on component, might be a bit less on this build.
edit 13/02/2024: Update to latest N64 changes and disabled PWM for scaled output as it was causing jitter.
edit 15/02/2024: Added Groovy core with PWM.
edit 28/02/2024: Update n64 and add Saturn Core.
edit 14/03/2024: Update n64 core, PWM is included as standard in Groovy now so you can download that from the official Github.
edit 08/04/2024: Update of all 3 cores to latest source.
edit 04/05/2024: Update all 3 cores.
edit 07/05/2024: N64 core had some vertical green lines on HDMI output, should be fixed now.
edit 12/06/2024: Update PSX and Saturn
edit 19/07/2024: Update PSX and Saturn
edit 15/08/2024: Updated N64(fixes for Conker's Bad fur day, Star Wars Naboo, Gauntlet Legends, Zelda MM telescope transition) and Saturn.
edit 18/08/2024: Updated N64
edit 24/08/2024: Updated Saturn
edit 31/08/2024: Updated PSX
edit 02/09/2024: Add repository for custom update_all database.
edit 24/09/2024: Add PSX 2X (Turbo) Core.
edit 02/10/2024: Add N64 Turbo core and update regular core.
edit 15/10/2024: Update Saturn
edit 22/11/2024: Update Saturn


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 9:15 pm
by lagerfeldt

Awesomeness


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 9:17 pm
by Bas

I'm not the sharpest tool in this shed... PWM?


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 9:36 pm
by FPGA64
Bas wrote: Sat Jan 13, 2024 9:17 pm

I'm not the sharpest tool in this shed... PWM?

Pulse width modulation


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 9:45 pm
by KennyL

I tested it a bit and it's really awesome. I had a lot of trouble with direct video setup so this option is really great. Really nice to regain dual output in my setup also. Is it possible put PWM in Saturn core and Groovy_mister?

Here's comparison on my small consumer Trinitron. My phone does a lot of color processing so please ignore the color. In person, PWM looks better than direct video on my setup. Brighter and smoother. Real PS1 is smoother still. YMMV.

Analogue IO board VGA, active Y/C board composite, PWM off

sotn-01-a-vga-pwm-off.jpg
sotn-01-a-vga-pwm-off.jpg (791.81 KiB) Viewed 21950 times

Analogue IO board VGA, active Y/C board composite, PWM on

sotn-01-b-vga-pwm-on.jpg
sotn-01-b-vga-pwm-on.jpg (769.1 KiB) Viewed 21950 times

Direct video (Benfei CS5210 chip), active Y/C board composite

sotn-01-d-direct-video.jpg
sotn-01-d-direct-video.jpg (771.48 KiB) Viewed 21950 times

Real PS1

sotn-01-c-real-psx.jpg
sotn-01-c-real-psx.jpg (644.8 KiB) Viewed 21950 times

Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 10:12 pm
by limi

Looking great!


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 10:43 pm
by bricabrac
Ruleset wrote: Sat Jan 13, 2024 6:53 pm

I have made a couple of builds that add PWM on the 18-bit DAC to get 24-bit color for the cores that need it. This is for any signal that uses the VGA port on the IO board. It works by quickly alternating between two different color values to get a color in between. The PWM happens very fast so it can be done even for 640 wide images.

This looks great on the pictures. Have to check it tomorrow. Many thanks for doing this as PSX really needs that 24bit colour and N64 will too.

I terms of tech solution am I correct that you somehow have access to the original, i.e. 24bit colour value, and then are trying to simulate it on 18bit DAC "filling" the gaps in colour resolution by incorporation the PWM?


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 11:06 pm
by Ruleset
bricabrac wrote: Sat Jan 13, 2024 10:43 pm
Ruleset wrote: Sat Jan 13, 2024 6:53 pm

I have made a couple of builds that add PWM on the 18-bit DAC to get 24-bit color for the cores that need it. This is for any signal that uses the VGA port on the IO board. It works by quickly alternating between two different color values to get a color in between. The PWM happens very fast so it can be done even for 640 wide images.

This looks great on the pictures. Have to check it tomorrow. Many thanks for doing this as PSX really needs that 24bit colour and N64 will too.

I terms of tech solution am I correct that you somehow have access to the original, i.e. 24bit colour value, and then are trying to simulate it on 18bit DAC "filling" the gaps in colour resolution by incorporation the PWM?

The original 24-bit color is already available for direct video and HDMI, PWM just pulses the right colors based on the 6 bits that are not sent to the 18-bit DAC.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Jan 13, 2024 11:23 pm
by Stinky

Great idea, real hacker solution!


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sun Jan 14, 2024 12:11 am
by PistolsAtDawn

I love this! Thank you!


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Jan 15, 2024 9:53 pm
by dyanand

Been trying out the PSX PWM core on my mister hooked up by component - what a huge difference! Awesome!


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Thu Jan 18, 2024 10:13 pm
by bricabrac

I confirm it is a night and day difference. Fantastic solution and something that truly deserves to be incorporated in MiSTer framework for all cores that can output 24bit colour to make use of its magic. Thank you for making it happen.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Jan 22, 2024 3:23 am
by KennyL

New updates (20210121) look great. Using PS1 240p Test Suite color bars, way less red shift on dark blues. Darkest reds and greens also look better. They looked kind of grayish previously. At least on my plasma tv via component.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Feb 05, 2024 8:42 pm
by mapf

I tested the last version for the N64. I have two setups that I can switch between. It works without problems on my 15KHz CRT TV.

When I use the analog output with a VGA monitor in higher resolutions, the PWM still gets applied (and color banding still seems to be reduced), but the image shows interference. It looks similar to dot crawl on composite connections, with edges showing moving bright pixels. It is clearly visible in the OSD, where all letters are jittery. The effect is more visible the higher the resolution.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Feb 05, 2024 9:38 pm
by Ruleset
mapf wrote: Mon Feb 05, 2024 8:42 pm

I tested the last version for the N64. I have two setups that I can switch between. It works without problems on my 15KHz CRT TV.

When I use the analog output with a VGA monitor in higher resolutions, the PWM still gets applied (and color banding still seems to be reduced), but the image shows interference. It looks similar to dot crawl on composite connections, with edges showing moving bright pixels. It is clearly visible in the OSD, where all letters are jittery. The effect is more visible the higher the resolution.

Yes, when using the scaler, PWM causes jitter. The scaler clock isn't fast enough to do PWM so it uses the video clock to do the modulation. But since the scaler and video clocks are different they don't align and end up jittering. I don't have a good solution for this yet, maybe PWM should just be disabled for the scaler output.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Mar 16, 2024 12:26 am
by naylord

wow this is sick. Why can't this be integrated into MiSTer main as an option for those that would want it?


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Mar 16, 2024 11:46 am
by Ruleset
naylord wrote: Sat Mar 16, 2024 12:26 am

wow this is sick. Why can't this be integrated into MiSTer main as an option for those that would want it?

I made a PR but Sorgelig wasn't interested. He said he preferred people getting a new 24-bit board over adding complexity to the framework.

I personally don't think it is too complex, but Sorgelig can probably judge that better.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Mar 16, 2024 10:33 pm
by naylord
Ruleset wrote: Sat Mar 16, 2024 11:46 am
naylord wrote: Sat Mar 16, 2024 12:26 am

wow this is sick. Why can't this be integrated into MiSTer main as an option for those that would want it?

I made a PR but Sorgelig wasn't interested. He said he preferred people getting a new 24-bit board over adding complexity to the framework.

I personally don't think it is too complex, but Sorgelig can probably judge that better.

That practically makes me tempted to put on a tinfoil hat that there's some sort of kickback arrangement on V2 board sales


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sun Mar 17, 2024 1:42 am
by Neocaron

It works great on a per core basis and it's transformative on Groovy, N64 and PSX core so you would think the feature should be part of the Mister framework, but since it doesn't stop the devs from integrating the feature anyway like Groovy did, it's not a terrible problem.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sun Mar 17, 2024 4:27 am
by naylord
Neocaron wrote: Sun Mar 17, 2024 1:42 am

It works great on a per core basis and it's transformative on Groovy, N64 and PSX core so you would think the feature should be part of the Mister framework, but since it doesn't stop the devs from integrating the feature anyway like Groovy did, it's not a terrible problem.

Right, though does this mean there has to be a new PWM release for every mainline N64/PSX/Groovy release that needs to be manually installed? Seems like a lot of maintence vs just integrating on main.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sun Mar 17, 2024 5:43 pm
by Neocaron
naylord wrote: Sun Mar 17, 2024 4:27 am
Neocaron wrote: Sun Mar 17, 2024 1:42 am

It works great on a per core basis and it's transformative on Groovy, N64 and PSX core so you would think the feature should be part of the Mister framework, but since it doesn't stop the devs from integrating the feature anyway like Groovy did, it's not a terrible problem.

Right, though does this mean there has to be a new PWM release for every mainline N64/PSX/Groovy release that needs to be manually installed? Seems like a lot of maintence vs just integrating on main.

Groovvy is fully integrated, but the N64 and PSX or Saturn isn't so yeah, It will need a constant update if you want it on the latest version.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Mar 18, 2024 6:58 pm
by mapf
Ruleset wrote: Mon Feb 05, 2024 9:38 pm

Yes, when using the scaler, PWM causes jitter. The scaler clock isn't fast enough to do PWM so it uses the video clock to do the modulation. But since the scaler and video clocks are different they don't align and end up jittering. I don't have a good solution for this yet, maybe PWM should just be disabled for the scaler output.

Did you find a solution for this? Can PWM be selectively disabled if the scaler is active? (Should also be disabled for direct video, I guess).


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Mar 18, 2024 8:02 pm
by Ruleset
mapf wrote: Mon Mar 18, 2024 6:58 pm
Ruleset wrote: Mon Feb 05, 2024 9:38 pm

Yes, when using the scaler, PWM causes jitter. The scaler clock isn't fast enough to do PWM so it uses the video clock to do the modulation. But since the scaler and video clocks are different they don't align and end up jittering. I don't have a good solution for this yet, maybe PWM should just be disabled for the scaler output.

Did you find a solution for this? Can PWM be selectively disabled if the scaler is active? (Should also be disabled for direct video, I guess).

PWM is disabled for scaled output in all builds after 13/02/2024. Direct video doesn't go through the VGA port so it is not affected by PWM.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Mon Mar 18, 2024 9:12 pm
by mapf
Ruleset wrote: Mon Mar 18, 2024 8:02 pm

PWM is disabled for scaled output in all builds after 13/02/2024. Direct video doesn't go through the VGA port so it is not affected by PWM.

That is what I get for only looking at the latest post in threads - found the updates in the first post :D


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Tue Mar 19, 2024 1:44 am
by naylord

Hello, any chance we can also get an rbf for the PSX 2x core? That one was a oneoff so one benefit is not only the 2X cpu but also that since there are no more updates, if we get PWM for it the core is basically perfect forever.

I still usually use the default 1X core, but 2x speed for increased frame rates is nice in certain games. Still, I like my slowdown in most games oddly enough; like in r-type delta I just think of it as a dynamic bullet time.

Also I'm curious if there's any value to older cores. Like I guess Genesis doesn't have enough colors on screen at a time to make 24 bit worth it? Or would it add value?


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Tue Mar 19, 2024 9:40 am
by Ruleset
naylord wrote: Tue Mar 19, 2024 1:44 am

Hello, any chance we can also get an rbf for the PSX 2x core? That one was a oneoff so one benefit is not only the 2X cpu but also that since there are no more updates, if we get PWM for it the core is basically perfect forever.

I still usually use the default 1X core, but 2x speed for increased frame rates is nice in certain games. Still, I like my slowdown in most games oddly enough; like in r-type delta I just think of it as a dynamic bullet time.

Also I'm curious if there's any value to older cores. Like I guess Genesis doesn't have enough colors on screen at a time to make 24 bit worth it? Or would it add value?

I am not sure if FPGAZumSpass ever released the 2x code.

Non 24-bit cores might benefit on YPbPr and S-Video/composite. I have seen some test on Discord that seem to show an improvement on these signals even when using non 24-bit color modes. I think this is because of how these signals are encoded.

A comparison that KennyL took on component, this was on the PSX core but the 240p test suite doesn't use 24-bit colors I believe. PWM off:

psx240p-01-a-component-pwm-off.png
psx240p-01-a-component-pwm-off.png (522.12 KiB) Viewed 17066 times

PWM on:

psx240p-01-b-component-pwm-on.png
psx240p-01-b-component-pwm-on.png (527.93 KiB) Viewed 17066 times

So it might be worth it for those signals.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Tue Mar 19, 2024 10:02 pm
by KennyL

It's a bit hard to see from the pictures I took above but psx 240p test color bars are not ramping smoothly via my analogue io board without PWM but they're much smoother with PWM. Very clear to see inperson. There are still spots that are not smooth but much better. It's impossible for me to tell the difference in actual psx in-game 15bit graphics though.

I have Misteraddons analogue io board and it would be interesting to see how smoothly color bars ramp on other analogue io boards.


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat Mar 23, 2024 9:18 pm
by naylord

It blows my mind that something this awesome isn't the top of all the mister news outlets. Like how is this not the subject of a videogame esoterica video/ pixel cherry ninja video yet?


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat May 04, 2024 8:08 am
by naylord
Ruleset wrote: Sat Jan 13, 2024 6:53 pm

I have made a couple of builds that add PWM on the 18-bit DAC to get 24-bit color for the cores that need it. This is for any non-scaled signals that use the VGA port on the IO board. It works by quickly alternating between two different color values to get a color in between. The PWM happens very fast so it can be done even for 640 wide images.

We have been testing it on the Mister FPGA discord, here are some pictures:
RGB SCART:
MisterN64CoreRGBPWM.jpg
Active Y/C S-video PWM off:
sotn-svid-01-a-pwm-off.jpg
Active Y/C S-video PWM on:
sotn-svid-01-b-pwm-on.jpg

I have included a build for N64, PSX and Saturn, PWM is always on in these builds, no settings needed.

Here is my fork of the N64 core with the PWM changes: https://github.com/Jokippo/N64_MiSTer_PWM

It seems to work quite well and may be a good alternative to using direct video or buying a new 24-bit IO board. For now, it looks like this won't be included in the MiSTer framework.

edit: Updated N64 core to most recent source. PSX core had some red color shift on component, might be a bit less on this build.
edit 13/02/2024: Update to latest N64 changes and disabled PWM for scaled output as it was causing jitter.
edit 15/02/2024: Added Groovy core with PWM.
edit 28/02/2024: Update n64 and add Saturn Core.
edit 14/03/2024: Update n64 core, PWM is included as standard in Groovy now so you can download that from the official Github.
edit 08/04/2024: Update of all 3 cores to latest source.

Thanks so much for this! I've been really enjoying it. In particular I love it on the Saturn since the saturn supports scandoubler so it works perfectly on my 31khz crt (I find scandoubler so much better than scaling anyway, everything just works perfectly unlike trying to find the right resolution and even then I find there's weird borders often and whatnot; lack of scandoubler is a pain on psx/n64 when trying to use my 31khz crt but that's another issue)

Would you be able to do a final update on the Saturn core when the core gets buttoned up? Feels like were in the homestretch of development and it would be amazing to have PWM on the final or near final release so it could be the definitive way of playing Saturn games.
Thanks so much again!


Re: PWM on 18-bit DAC to get 24-bit Color

Posted: Sat May 04, 2024 5:45 pm
by Ruleset
naylord wrote: Sat May 04, 2024 8:08 am

Would you be able to do a final update on the Saturn core when the core gets buttoned up? Feels like were in the homestretch of development and it would be amazing to have PWM on the final or near final release so it could be the definitive way of playing Saturn games.
Thanks so much again!

I'll make new builds probably about once a month if there are updates. Cores are updated to latest source today.