Direct Color Demo using DMA
Moderator: Mask of Destiny
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Regarding Stef's idea about Z doing things, well it won't work because bus is locked and when Z accesses 68K side during DMA it will also be halted like 68K, until DMA ends.
Mida sa loed ? Nagunii aru ei saa ![Wink ;)](./images/smilies/icon_wink.gif)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
![Wink ;)](./images/smilies/icon_wink.gif)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Those work because the CPU clock is locked to the VDP clock AND you have access to a cycle accurate raster position. The raster position on the Genesis doesn't have the lsb, so you'll never be more accurate than 2 pixels. It doesn't help that the minimum clock cycles for instructions on the 68000 is 4, most are 8 to 14 cycles, and there are NO odd cycle instructions.
It shouldn't be a problem - any latency should just shift the image right a pixel - hopefully it's consistent and not intermittent, which would cause jitter. That is one reason I want to make a demo checking how it works from word ram... just to be sure.bgvanbur wrote:This makes me wonder about the sensitivities of using Word RAM for VDP DMA.Chilly Willy wrote:To give you an idea of how sensitive this is, the loop in work ram starts the DMA 6 pixels earlier than the same code in rom.
The synchronization is done based on the vertical count. The horizontal position is based purely on cycle counting.Chilly Willy wrote:Those work because the CPU clock is locked to the VDP clock AND you have access to a cycle accurate raster position. The raster position on the Genesis doesn't have the lsb, so you'll never be more accurate than 2 pixels.
Repeating the jitter correction for two consecutive lines would give a 2 cycle accuracy. If the cycle count/line isn't constant and predictable then the scheme obviously does not work.It doesn't help that the minimum clock cycles for instructions on the 68000 is 4, most are 8 to 14 cycles, and there are NO odd cycle instructions.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Well, I got H32 mode stable... just comment out one of the NOPs after the 13 word stores. That's it.
However, there's a BIG problem with H32 mode and DMA color: 161 wide shears to the left, and 162 wide shears to the right. Apparently it's 161.5 wide!
So I don't think H32 and DMA color is going to be useful.![Sad :(](./images/smilies/icon_sad.gif)
EDIT: Well, I suppose you COULD draw the buffer such that every other line was 161 and the other lines were 162. That should average out to rectangular, but every other line will be a half pixel off from the others. Not to mention that makes calculating the offset to draw to a bit harder, but it SHOULD work.
EDIT 2: Well, finally got some free time and tried the 161/162 trick and found something interesting... it IS 161. For some reason, if I save the BMP as 161 wide and convert it, it's not converting right. Maybe BMPs pad for odd widths... when I save as 162 and then only write 161 pixels per line, it looks perfect on the screen. Go figure...
Anywho, I'll post a demo in a bit when I clean things up a little... need to adjust the display a little as it doesn't start at the same place as H40 mode, so I need a bit of padding to start to center the image.
EDIT 3: Here's the demo. Images are 161x224 with a visible width of 128. The converter takes a 162x224 BMP and outputs a 161x224 binary.
http://www.mediafire.com/?88jfs5ztav8k9a8
However, there's a BIG problem with H32 mode and DMA color: 161 wide shears to the left, and 162 wide shears to the right. Apparently it's 161.5 wide!
So I don't think H32 and DMA color is going to be useful.
![Sad :(](./images/smilies/icon_sad.gif)
EDIT: Well, I suppose you COULD draw the buffer such that every other line was 161 and the other lines were 162. That should average out to rectangular, but every other line will be a half pixel off from the others. Not to mention that makes calculating the offset to draw to a bit harder, but it SHOULD work.
EDIT 2: Well, finally got some free time and tried the 161/162 trick and found something interesting... it IS 161. For some reason, if I save the BMP as 161 wide and convert it, it's not converting right. Maybe BMPs pad for odd widths... when I save as 162 and then only write 161 pixels per line, it looks perfect on the screen. Go figure...
![Laughing :lol:](./images/smilies/icon_lol.gif)
Anywho, I'll post a demo in a bit when I clean things up a little... need to adjust the display a little as it doesn't start at the same place as H40 mode, so I need a bit of padding to start to center the image.
EDIT 3: Here's the demo. Images are 161x224 with a visible width of 128. The converter takes a 162x224 BMP and outputs a 161x224 binary.
http://www.mediafire.com/?88jfs5ztav8k9a8
Good news everyone I have finished my own converter. I call it Image to direct color and back again meaning that it can take a image in major formats (I tested it with png and jpg) and convert it to direct image and then convert the direct color image back to an image readable. It supports floyd steinburg dithering so the images look good and no more messing around with plugins it is a one click solution. Here is the format for using the program
for -m you can use -i2 -i3
-i2 means that it will convert the image to direct color with BGR 233
-i3 means that the image will be converted to a direct color image using the standard sega genesis palette format
-o means that it will convert both types of direct color image back to a normal image reable by a image editor
-o will automatically determine which type of direct color image it is based on filesize
Note the direct color images generated by this program have a 4 byte header
Width height are both stored in 2 byte big endian
-t will generate a BGR233 to sega genesis table NOTE: when using this mode leave output blank
Here is a sample image from the converter
Original:
![Image](http://geekwithcomputer.com/tumblr_lje4gn58Co1qath3qo1_500.jpg)
Sega genesis palette
![Image](http://geekwithcomputer.com/test3_3.png)
BGR 233
![Image](http://geekwithcomputer.com/test3_2.png)
As you can see BGR 233 loses 1 bit of blue but takes up half the memory
You can read more about this on my website
http://geekwithcomputer.com/directcolor.html
And download the program and source here:
http://geekwithcomputer.com/direct_colo ... er_v_2.zip
Please tell me what you think about it and I do hope you like it.
Code: Select all
directconvert -m input output
-i2 means that it will convert the image to direct color with BGR 233
-i3 means that the image will be converted to a direct color image using the standard sega genesis palette format
-o means that it will convert both types of direct color image back to a normal image reable by a image editor
-o will automatically determine which type of direct color image it is based on filesize
Note the direct color images generated by this program have a 4 byte header
Width height are both stored in 2 byte big endian
-t will generate a BGR233 to sega genesis table NOTE: when using this mode leave output blank
Here is a sample image from the converter
Original:
![Image](http://geekwithcomputer.com/tumblr_lje4gn58Co1qath3qo1_500.jpg)
Sega genesis palette
![Image](http://geekwithcomputer.com/test3_3.png)
BGR 233
![Image](http://geekwithcomputer.com/test3_2.png)
As you can see BGR 233 loses 1 bit of blue but takes up half the memory
You can read more about this on my website
http://geekwithcomputer.com/directcolor.html
And download the program and source here:
http://geekwithcomputer.com/direct_colo ... er_v_2.zip
Please tell me what you think about it and I do hope you like it.
Last edited by sega16 on Sat Mar 09, 2013 5:14 pm, edited 3 times in total.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Nifty! Can't wait to try it. Oh - your website is really awesome, but it's spelled A W E S O M E. ![Very Happy :D](./images/smilies/icon_biggrin.gif)
EDIT: To compile in linux, use this line:
CImg is in the Ubuntu repo, so you can install it with Synaptic or "apt-get install cimg-dev". Which brings me to a bug... in main.cpp, you have:
when it should be
That doesn't matter in Windows, but does in every other OS. You also put "Written by sega" when you probably meant "sega16".
![Laughing :lol:](./images/smilies/icon_lol.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
EDIT: To compile in linux, use this line:
Code: Select all
g++ -o directconvert main.cpp -lpthread -lX11 -lpng -lz -lstdc++
Code: Select all
#include "Cimg.h"
Code: Select all
#include "CImg.h"
![Wink :wink:](./images/smilies/icon_wink.gif)
![Laughing :lol:](./images/smilies/icon_lol.gif)
I fixed my site I remember looking at the logo and thinking something is not right I guess that was it.The online text generator I used had some odd glitch were even if I right click enable check spelling in the text box were the text is to be entered it did not show the red line under the misspelled word. I have never had that happen before I think it has to do with the website and not with firefox.
Edit: fixed program I can not believe all the typos that are slipping by my head.
Edit: fixed program I can not believe all the typos that are slipping by my head.
Last edited by sega16 on Thu Jul 26, 2012 3:40 am, edited 1 time in total.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Probably. My problem is I sometimes don't hit the keys hard enough to register, then I'll hit return before noticing I missed the letter. It's especially bad with keys I need to hit with the left pinky or ring finger.sega16 wrote:I fixed my site I remember looking at the logo and thinking something is not right I guess that was it.The online text generator I used had some odd glitch were even if I right click enable check spelling in the text box were the text is to be entered it did not show the red line under the misspelled word. I have never had that happen before I think it has to do with the website and not with firefox.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Here's a demo of a few 160x224 scifi images run thru the converter... very good. I don't think I could do better with GIMP and that ximagic plugin.
http://www.mediafire.com/?7jv67j62k4xxjw0
http://www.mediafire.com/?7jv67j62k4xxjw0