It's Fonzie very fault ! He convinced me ... well, sort of, to think about a Super VDP. Met's face it : the 32X wasn't a 2D crusher, and he had wonderful processors. So, can't I do something more ? Sure I can !!!! Please, follow me in my Super VDP thing.
First of all, we tidy up some ideas : the 32X can do scrolling. I'm not talking about the Shift bit. I'm talking about true scrolling. Let me be clear : it's simple, but it's possible. There are 2 scrollings you can easily do : lines horizontal scrolling and full screen vertical scrolling. Let's start with the horizontal scrolling.
The screen is 640 x 200. There remains 40 lines, 20 up and 20 down. These lines, that we'll set to black, will be at 1 FEC0h in DRAM. The line table data is from 0h to 200h. The line data start at 200h. One 640 pixel width line is 280h bytes, with the packed byte setting.
Here's what the line table data looks like :
0h (line 0) : 1FEC0h
2h (line 1) : 1FEC0h
4h (line 2) : 1FEC0h
...
28h (line 20) : 200h
2Ah (line 21) : 480h
2Ch (line 22) : 700h
2Eh (line 23) : 980h
30h (line 24) : C00h
...
Then, to offset the 23th line with 45h pixel, you just modify the table line data, writing 980 + 45 at 2E. Et voilà ! The offset is module 320.
Let's move on the vertical scrolling.
The screen is 320 x 400, one line will be 140h pixel (so, byte) and the table line data will be :
0h (line 0) : 1FEC0h
2h (line 1) : 1FEC0h
4h (line 2) : 1FEC0h
...
28h (line 20) : 200h
2Ah (line 21) : 340h
2Ch (line 22) : 480h
2Eh (line 23) : 5C0h
30h (line 24) : 700h
...
And, to scroll the full screen 45 line down, you just add 45 x 140 to each value in the line table data. Et voilà ! (bis)
Yes, I know. This scrolling can only be done once the Frame Buffer has been entirely drawn.
So, I'm thinking of a better VDP. My aim is 4 layers. The data would be in SDRAM, and the SH2 would move the data from SDRAM to the Frame Buffer.
The vFlip and hFlip would be implemented, plus a rotate right 90°. Moreover, I want a transparency setting.
Here's the vFlip :
Code: Select all
for (line 0 to 8)
for (col 0 to 8)
dest[8-line][col] = src[line][col]
Code: Select all
for (line 0 to 8)
for (col 0 to 8)
dest[line][8-col] = src[line][col]
Code: Select all
for (line 0 to 8)
for (col 0 to 8)
dest[col][8-line] = src[line][col]
The transparency I want to do is the mean : (c1 + c2) / 2. Be careful : I use packed color, so 1 byte/pixel, as an entry. Since in this mode, I use a palette entry, my palette has to be defined as a RGB composante : let's say RRRGGBBB. To do transparency, first of all, I have to get the color, and not the palette entry. Then, I have to extract each composante :
color & 0x7 // blue
color & 0x18 // green
color & 0xE0 // red
Then, I make the mean for each of these composantes :
new_blue = (blue1 + blue2) / 2
new_green = (green1 + green2)/2
new_red = (red1+red2)/2
Then, I build the new color with the 3 composantes, and return back the nearest color in the palette entries.
I'm sure we could find tons of other way to make transparency, multiply, substract, or add a coefficient. For now, I'll stick with this way.
Regarding the 32X VDP, and especially the FILL function, there's a mistake. The Hardware Manual (§3.3) states "Because VDP and SH2 DRAM accesses conflict while executing Auto Fill, do not access from SH2". Virtua Racing Deluxe largely uses the VDP from SH2. Anyway, the 32X VDP cannot do anything a VDP should do.