Talk:Using the hardware blitter


Interestingly in the MMSP2 DataBook v1.0 the address of the 2D Graphics Accelerator is cited as E0024000. Well, after I've checked the given link to the GP32x forums I saw that the last post dates from 2005. That was from exactly one year ago. So, I wonder if this code still works because as I aforementioned MMSP2 DataBook v1.0 says that the address of the 2D Graphics Accelerator is E0024000 which is said to be E0020000 by this article and the MMSP DataBook v0.95.

The address doesn't seem to matter mutch, both E0024000 and E0020000 work for me. In fact, it seems the blitter can be accessed using many other addresses, I tried some "stupid" addresses like F0020000 and EEE20000, and they worked. --Notaz 06:35, 16 February 2007 (PST)

Hmm, the pharagraph above does not belong to me, I guessed that wiki will handle it for me. My discussion is below (sorry I am new to wiki :))

About the section " Blitting itself", article says that 2nd frame buffer is at "0x3101000 + 320*240*2". Yes, it seems so at first but when we look at the upper 32MB memory table things are not like that.

Address Length Usage
0x03000000 342812 bytes Video decoding firmware
0x03101000 153600 bytes Primary frame buffer
0x03381000 153600 bytes Secondary frame buffer
0x03600000 16384 bytes Sound buffer
0x03D00000 up to 0x03FFFFFF Reserved for internal buffers of MPEG H/W decoder

0x3101000 + 320*240*2 Takes us no where according to the table above. Because primary frame buffer starts at 0x03101000 and it is size is 320*240*2 = 153600 bytes. And if we add 153600 to the primary frame buffer address we get 0x3126800. But the idea was to get 2nd frame buffer's address and it is: 0x3381000

So writing "0x3101000 + 320*240*2" to the source buffer section in the blitting code seemed wrong to me. I think article writer guessed that, that leads to 2nd frame buffer. That should be changed with 2nd frame buffer's address(0x03381000).

I didn't want to edit the page directly because I am a newbie and I may make mistake somewhere :) Please someone correct me if I am wrong.

Some pseudo code that explains what I want to tell(and this works for me) :

fb0 = mmap(0, 320*240*2, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0x3101000); // 1st frame buffer
fb1 = mmap(0, 320*240*2, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0x3381000); // 2nd frame buffer

//Wait till the blitter is ready
  while(blitter32[0x0034 >> 2] & 1) usleep(1);

  //Set the destination as 16bit and enable it for use.
  blitter32[0x0000 >> 2] = (1 << 5) | (1 << 6);
  //Set the address of destination
  blitter32[0x0004 >> 2] = 0x3101000;
  //Set the pitch of destination in bytes.
  blitter32[0x0008 >> 2] = 320*2;
  //Set a 16bit source, enable source and say the source is not controlled by CPU(?)
  blitter32[0x000C >> 2] = (1 << 8) | (1 << 7) | (1 << 5);
  //Set the source address
  blitter32[0x0010 >> 2] = 0x3381000;
  //Set the pitch of source in bytes
  blitter32[0x0014 >> 2] = 320*2;
  //Do nothing with patern
  blitter32[0x0020 >> 2] = 0;
  //Set the size 320 by 240
  blitter32[0x002C >> 2] = (240 << 16) | (320 << 0);
  //Clear the source input FIFO, positive X,Y. And do a copy ROP.
  blitter32[0x0030 >> 2] = (1 << 10) | (1 << 9) | (1 << 8) | 0xCC;
  //Make the blitter run.
  blitter32[0x0034 >> 2] = 0x0001;

Personal tools