GP2X Blitter Destination With Non %4 Offset?


GernotFrisch

Member
Joined
Jan 2, 2007
Messages
445
Hi,

I have this blitter code so far:
Code:
void gp2x_blit(unsigned int hardware_ptr, int x, int y, int w, int h)
{
int x_from=31; int y_from=31;


	blitter32[0x4 >> 2] = (0x3381000 + (y*640) + (x<<1) ) & ~3; // dest ptr
	blitter32[0x0] = 1<<5  | ((x & 0x00000001) << 4); 			// Destination is 16 bpp
	blitter32[0x8 >> 2] = 640;									// Destination stride size in bytes

	//Set the source address


	// I'm missing something here??
	
	blitter32[0x0010 >> 2] = (hardware_ptr +(y_from*640)+(x_from<<1) )&~3;
	//Set the pitch of source in bytes
	blitter32[0x0014 >> 2] = 640;
	//Do nothing with pattern
	blitter32[0x0020 >> 2] = 0;


	// Set a 16bit source, enable source and say the source is not controlled by CPU(?)
	blitter32[0x000C >> 2] = (1 << 8) | (1 << 7) | (1 << 5);


	// Clear the source input FIFO, positive X,Y. And do a copy ROP.
	blitter32[0x0030 >> 2] = (1 << 10) | (1 << 9) | (1 << 8) | 0xCC;

	blitter32[0x2c >> 2] = (h << 16) | (w << 0);				// Height and width to blit

	// Wait for blitter to be free, start it, and then wait for completion.
	// Throw in some nop's so we don't saturate the address bus with polling requests.
	while (blitter32[0x0034 >> 2] & 1)
	{
		asm volatile ("nop");
		asm volatile ("nop");
		asm volatile ("nop");
		asm volatile ("nop");
	}
	blitter32[0x34 >> 2] = 1;
	gp2x_dummy_blit();
}
But, the desitnation rectangle seems offset by 1 byte. Am I missing something?

What's more: Can anyone tell me how to specify a transparent color in source?
 
If image is offset by 1 byte, you should use fraction parameter (DSTFRAC, first 5 bits of DSTCTRL (0xE0024000).

For transparency, you should use the CTRL register (0xE0024030) bits 11-31.
 
Squidge posted on Feb 4 2007 at 10:42 AM said:
If image is offset by 1 byte, you should use fraction parameter (DSTFRAC, first 5 bits of DSTCTRL (0xE0024000).

For transparency, you should use the CTRL register (0xE0024030) bits 11-31.

Seps say: if BPP ==16: freaction = (x%2)*16, which is what I did:
blitter32[0x0] = 1 <<5 | ((x&0x00000001) <<4)

???
Is there something for source as well?
 
Last edited by a moderator:
Yeah, the same applies for source aswell.
And it seems like you first and with ~3 both on the source and the
target address. And then apply the fraction.
I'm not 100% sure thats the way it should be done, the doc says that:
If image is not aligned as WORD (32 bit), Fraction parameter should be set. Fraction parameter defines offset value of
image by 32 bit units.
So i think you should keep your adresses unaligned, but set the fraction.
I might be wrong however, i haven't been playing around with the blitter
for a while.
 
I talked to Kungphoo on IRC yesterday, and he was jumping about shortly afterwards, so I can only assume he got his blitter code working :)
 
Squidge posted on Feb 5 2007 at 06:36 PM said:
I talked to Kungphoo on IRC yesterday, and he was jumping about shortly afterwards, so I can only assume he got his blitter code working :)

Yes. See the "Blitter - the code" thread. It works awesomely fast and without any problems. Huge, huge "thank you".
 
Last edited by a moderator:
Back
Top