Direct Color Demo using DMA

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jul 26, 2012 5:31 am

I was looking at the demo I posted and had a thought - how about an option to not dither areas of flat color, but rather accept some error in the color. For example, look at space above the earth in the Capt Harlock image... it would look better not dithered, even if it were a shade lighter or darker than it should be. Maybe a switch so that if an area has little or no detail, it uses no dithering.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Jul 26, 2012 7:25 am

I wouldn't think dithering so early is a good option, especially when one is to resize the image in some other program...

nice stuff though ^^
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jul 26, 2012 7:35 am

TmEE co.(TM) wrote:I wouldn't think dithering so early is a good option, especially when one is to resize the image in some other program...

nice stuff though ^^
If you look at my last demo, I resize the images first, then run them through the converter as the last step (the converter alters the colors and dithers, then stores in the format we need for DMAing). That's actually partly why I asked for the switch on dithering - dithering a 160x224 image makes the dithering quite noticeable.

bgvanbur
Interested
Posts: 46
Joined: Fri Jun 22, 2012 11:13 pm

Post by bgvanbur » Thu Jul 26, 2012 2:48 pm

While Floyd-Steinberg is great for static images, it sucks for movies since the error correcting aspect makes static pixels change often even if the static pixels are very far away from the changing pixels (and makes it hurts compression since you cannot reuse pixels from previous frames for what should be static pixels). Most movies try to use a deterministic dither (such as ordered dithering) instead of an error correcting dither so that static pixels do not change. I have an Sega CD ISO coming out soon that will showcase this issue of Floyd-Steinberg vs ordered dithering, but I cannot release it until after the weekend.

My SCDTools support color ordered dithering (for 2x2, 4x2, 2x4, 4x4, and 8x8) and I have just added direct color support to scdimgvdppalette (a tool to convert an image using sega VDP restrictions).

Example call:

Code: Select all

scdimgvdppalette -directcolor -dither=2x2 sample.jpg
2x2 ordered dithering

Image

4x4 ordered dithering

Image

8x8 ordered dithering

Image

4x2 ordered dithering to a regular 16 color single palette in case you were wondering :)

Image

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Thu Jul 26, 2012 3:39 pm

I am starting to look into Riemersma dithering this website http://www.compuphase.com/riemer.htm says
It thereby combines the advantages of ordered dither and error diffusion dither
If that turns out to be true it would be the best solution for FMV and static images. I will probably add it soon.

bgvanbur
Interested
Posts: 46
Joined: Fri Jun 22, 2012 11:13 pm

Post by bgvanbur » Thu Jul 26, 2012 4:51 pm

sega16 wrote:I am starting to look into Riemersma dithering this website http://www.compuphase.com/riemer.htm says
It thereby combines the advantages of ordered dither and error diffusion dither
If that turns out to be true it would be the best solution for FMV and static images. I will probably add it soon.
scdimgvdppalette also support Riemersma too using ImageMagick's implementation of Riemersma.

Code: Select all

scdimgvdppalette sample.jpg -directcolor -dither=r
Image

Even though it supposed to have a small area for error correction, the Riemersma still occasionally has a wide area of error diffusion which causes issues for large areas of static pixels still. For example on a video I converted to Cinepak for Sega (CD) with a static background for about 50% of the pixels, Floyd-Steinberg managed 5 fps, ~Riemersma manages 6 fps (too many static pixels changing making it so tiles could not be reused), but 4x2 ordered dithering got 12 fps.

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Thu Jul 26, 2012 8:24 pm

My converter now supports Riemersma dithering
http://geekwithcomputer.com/direct_colo ... er_v_2.zip
To use Riemersma dithering use -i2r or -i3r instead of -i2 or -i3 depending on the color depth that you want.
Here is a sample output
Image
I personally think Riemersma dithering looks abit better.
This website http://bisqwit.iki.fi/story/howto/dither/jy/ has some different order dither algorithms I will implant them next version.
Last edited by sega16 on Wed Feb 13, 2013 11:10 pm, edited 1 time in total.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Jul 29, 2012 2:03 am

Okay! Some of you wondered how this would work from CD Word RAM... a good question. So I broke out a SCD boot loader I wrote last year and debugged it, then made a demo for the SCD... and here it is.

http://www.mediafire.com/?asbz9vzhynzefb5

The archive includes all source and a test ISO. It runs on my CDX and Model 2 CD/32X. The 160 mode looks fine, but the 128 mode isn't stable (again). I'll play around with it more when I can get up the gumption to give a f-ck. :lol:

To actually make the ISO, you need the boot loader binary, so here's the boot loader, source and all.

http://www.mediafire.com/?8dg63knv2cqcrex

This boot loader is a little different than most - it doesn't boot the first file, it searches the root directory for a particular file (set currently in the source to "APP.BIN" ). It also loads the app to 0x8000 (most others I've seen load to 0x6800 or 0x7000). I load to 0x8000 to leave the lower ram available for short absolute addressed variables. Finally, when the first app returns to the loader, it can pass a string as the result which the loader will then search through the root directory for to load and run. That allows people to make a dispatch app to run one of several programs quite easily. To get an idea of an example app, see the cd dma demo above.
:D

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Sun Jul 29, 2012 3:24 am

Wow this was very cool to see on my television I think it was worth the cd-r I am glad to see that my dithering theory kind of worked (have the television blend the two pixels) Here is a picture of the image that in my opion turned out best:
http://img853.imageshack.us/img853/7959/crw0642.jpg
Edit image to big click link
(sorry about the color rendition it is off abit when taking a picture of a television you can never win.)
Also one thing that I would like to point out I have found a glitch in my BGR 233 table generator if anybody tried to do anything with that and wondered why it did not work that is why here is the fixed and working code

Code: Select all

if (switcher.compare("-t")==0)
	{
			//to make this an effective table we need to make it in such away so that the table can be accesed and require no additional math
			//so we simply order table from smallest to largest number
			cout << "saving table to: " << argv[2] << endl;
			ofstream outfile (argv[2]);
			if (outfile.is_open())
			{
				outfile << "//make sure that the varible used is 2 bytes" << endl;
				outfile << "const unsigned int[]={" << endl;
				//red
				for (x=0;x<=252;x+=36)//blue
				{
					for (y=0;y<=252;y+=36)//green
					{
						for (z=0;z<=252;z+=36)//red
						{
							count++;
							outfile << "0x" << hex << rgb_to_genesis(z,y,blue2to4bit[x/36]) << ",//color # " << dec << count << endl;
						}
					}
				}

				//write final value
				outfile.close();
				return 0;
			}
			else
			{
				cout << "Error while trying to create file: " << argv[2] << endl;
				return -1;
			}
	}
Now that the image is in ram I think that this has much more potential for real time rendering/drawing of stuff

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Jul 29, 2012 4:06 am

I tried it, but it wasn't too much use until I got this cd demo working. When showing images in rom, you're stuck with dci3. Now I can work on a demo to play video from CD... I'll probably allow the use of dci2 format.

I should make a cd program that displays the directory on a cd and allows you to select files to display. That would make it easier to check how your algorithms affect the display on this mode.

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Sun Jul 29, 2012 4:28 am

That would be very cool having a sega cd bootloader that allows me to load different programs and test them and not have the limits of basigeaxorz There is some stuff I would like to try out now that I have away to test this I think it is the next big thing with genesis development that is why I made the converter to have a one click easy way to generate images so that is very simple to use and that should help more people quickly make use of direct color. Direct color opens up so many possibilities especially with real-time effects.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Jul 29, 2012 4:41 am

sega16 wrote:That would be very cool having a sega cd bootloader that allows me to load different programs and test them and not have the limits of basigeaxorz There is some stuff I would like to try out now that I have away to test this I think it is the next big thing with genesis development that is why I made the converter to have a one click easy way to generate images so that is very simple to use and that should help more people quickly make use of direct color. Direct color opens up so many possibilities especially with real-time effects.
Yep, all kinds of stuff is open... I can get back onto Wolf3D-CD now that I've shown dma color works from word ram. I'm sure there are tons of things that can be done now that there's a direct bitmap mode... no more having the translate into cells, ability to change frames at 60Hz - yeah, almost forgot to mention that plus: 60 Hz bitmaps are a reality!

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Jul 29, 2012 10:10 pm

Oh, one more bug on the cd boot loader - at line 210 you find

Code: Select all

        lea     LOAD_BUFFER.w,a1
That should be

Code: Select all

        lea     LOAD_BUFFER.l,a1
The load address is 0x8000 (as I mentioned before), so .w would sign extend the address to 0xFFFF8000, which is wrong. It should be .l to be 0x00008000. That would have prevented it from loading any file passed back by APP.BIN. That was my main bug I corrected yesterday - APP.BIN was being loaded to 0x8000.w instead of 0x8000.l. :D

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Jul 30, 2012 11:08 pm

Here's a European CD... it works in Gens/GS set to European BIOS, but I don't have real hardware to test on... all my stuff is US.

http://www.mediafire.com/?3pss9hims4aray9

Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Tue Jul 31, 2012 2:37 am

Wow, kudos to everyone who's contributed to this technique. I worked on the exact same thing: getting a stable horizontal raster position and modifying the background colour to display a full colour image, just six months or so back, and I couldn't get it stable, there was always jitter, and after that experiment I honestly had believed getting a stable position was impossible. Well done guys, this is a major step forward.

Post Reply