Frame Buffer Switch

Ask anything your want about the 32X Mushroom programming.

Moderator: BigEvilCorporation

Post Reply
ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Frame Buffer Switch

Post by ob1 » Mon Feb 05, 2007 9:04 am

Just a little question.
The 32X has 2 frame buffer : FB0 and FB1. When FB0 is displayed, I can write to FB1. Calling the frame buffer swap, FB1 is displayed and I can write to FB0. But is this frame buffer emptied or does it still have previous data ?

eg :
FS = 0
I draw a red triangle.
FS = 1
I draw a green polygon.
FS = 0
Is DRAM = 0, or does it still have a red triangle ?

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Mon Feb 05, 2007 9:16 am

It does still have data, unfortunately (or fortunately)...
You may use "data fill" command to clear the ram automaticaly while doing something else...

Also just keep in mind that you can remap yourself the vertical line display... It can be used for vertical/horizontal scrolling without having to redraw all.

Also, you have two "windows" to acess the buffer, one have "overwrite mode" (standard ram mode), and one have "mergewrite mode" where 0 data isn't written. It can be very usefull to draw sprites over existing background (without having to care about the 0 data transparency).

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Mon Feb 05, 2007 9:22 am

I was wondering what that FILL function was for ! I didn't see the use since the Run-Length is fine for continous pixels (if less than 255). FILL for clear, why not.

The doc states the FILL execution time is 7+3xlength, and the SH2 to DRAM execution time is 1-3 cycles. Is the FILL faster than direct access (funny : I've put the same statement about DMA fill and 68k ;) ) ?

I haven't dig the SH2 DMA, but I don't think it would be that helpful.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Mon Feb 05, 2007 9:27 am

RLE vdp mode and FILL mode is different.

RLE vdp mode is a translation of the FB to RLE data while sending to TV.
FILL mode is a simple hardware filling (255 words/int or bytes? max, yeah?).

Since the Fill mode is done in hardware, it may just be used if you want to do some heavy calculus (waiting the fill to finish).
Another trick would be to be sure that you completely overdraw the previous picture (its easy in a raycaster but hard in a 3d engine).

Fill can also be used to do flat polygons... If you draw them by vertical lines... héhé ;) Or clearing buffer, yes ;)


I never used the Fill hardware, btw...
PS : haha, je suis sur que tu sais déjà tout ça, mais dans le cas où... désolé si je radote :)

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Mon Feb 05, 2007 9:50 am

I thought they were quite the same. Can't I do the same things ?

Let's suppose I want to draw a 165 pixels long red line, from pixel 48, the others being black.

With RLE :
2F00h, A401h, 6A00h
with palette :
00h : 0000h black
02h : 7C00h red

With FILL :
002Fh, 2000h, 0000h
00A4h, start address is already changed, 0101h
006Ah, start address is already changed, 0000h

I can even use FILL for 16 bits rendering :
002Fh, 2000h, 0000h
004Ah, start address is already changed, 7C00h
006Ah, start address is already changed, 0000h

Anyway, yes, I'm wondering about a 3d engine (GLide, anyone ?). So I'd need (note the would need, since I start a lot of things but don't complete a lot ;) !) to clear the frame buffer I've just received. Here's how I'd clean it, using FILL :

Code: Select all

void clearFrameBuffer() {
	int line;
	(int *) FILL_LENGTH = (int *) 0x20004104;
	(int *) FILL_START = (int *) 0x20004106;
	(int *) FILL_DATA = (int *) 0x20004108;
	(int *) FB_CTRL_REG = (int *) 0x2000410A;

	*FILL_LENGTH = 0xff;
	*FILL_START = 0x200;

	for (line=0;line<256;line++) {
		*FILL_DATA = 0;
		while (!(*FB_CTRL_REG & 2)) ; // wait for FEN = 0
	}
}
Even if FILL is hardware, one SH2 has to watch it, wait for FEN. Meanwhile, I guess the other SH2 doesn't have access to Frame Buffer.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Mon Feb 05, 2007 10:14 am

Ho, i see... u want to use an existing 3d engine :wink: :twisted: Haha, great :D But it will be harder, yes.

"I thought they were quite the same. Can't I do the same things ?"
Umm, nope, RLE means the framebuffer is compressed like RLE.
Fill = hardware fills the framebuffer data.

Sega 32x Framebuffer have three mode:
RLE (1byte data, 1byte repeat) (0-255 pixels per word) < Use palette
PACKED (byte data, 1byte data) (2pixels per word) < Use palette
TRUE COLOR (1word data) (1pixel per word) < Don't use palette

For now, you should clear in 100% software... Really... héhé :D

Post Reply