marmakoide
Still Fresh
Hi all
I'm trying to use the blitter to fill rectangle with a single color. By reading the harware optimised SDL, I do this way :
1) Magic to enable the blitter operations
2) Now blitting the rectangle
The 'BLITTER_REG_XXX' comes from the MMSP2 manual. My code freeze the GP2X without displaying anything when I perform that
What I missed ?
I'm trying to use the blitter to fill rectangle with a single color. By reading the harware optimised SDL, I do this way :
1) Magic to enable the blitter operations
Code:
gp2x_mem_fd = open("/dev/mem", O_RDWR);
blitter_regs_32 = (unsigned int*)mmap(0, 256, 3, MAP_SHARED, gp2x_mem_fd, 0xe0020000);
... doing stuffs...
/* init the screen to 320x240 16bpp */
mmsp2_regs_16[0x28da >> 1] = 0x004ab;
mmsp2_regs_16[0x290c >> 1] = 640;
/* enable the hardware acceleration */
mmsp2_regs_16[0x090a >> 1] = 0xffff;
mmsp2_regs_16[0x0904 >> 1] |= (1 << 10);
2) Now blitting the rectangle
Code:
void
gp2x_blitter_areaFill(const void* offset,
unsigned int x, unsigned int y,
int width, int height,
unsigned short col) {
unsigned int lOffset;
unsigned int lDstCtrl;
/* Compute the adress of the upper left corner */
lOffset = ((unsigned int)offset) + (y * 640) + (x << 1);
lDstCtrl = (1 << 5) | ((x & 0x00000001) << 4);
/* Wait until the blitter is not busy */
do {} while(blitter_regs_32[BLITTER_REG_RUN >> 2] & 0x01);
/* Set the destination */
blitter_regs_32[BLITTER_REG_DSTCTRL >> 2] = lDstCtrl;
blitter_regs_32[BLITTER_REG_DSTADDR >> 2] = lOffset & ~3;
blitter_regs_32[BLITTER_REG_DSTSTRIDE >> 2] = 640;
blitter_regs_32[BLITTER_REG_SRCCTRL >> 2] = 0;
/* Set the filling pattern */
blitter_regs_32[BLITTER_REG_PATCTRL >> 2] = (1 << 5) | (1 << 4);
blitter_regs_32[BLITTER_REG_PATFORCOLOR >> 2] = col;
blitter_regs_32[BLITTER_REG_PATBACKCOLOR >> 2] = col;
/* Set the size of the rectangle */
blitter_regs_32[BLITTER_REG_SIZE >> 2] = (height << 16) | width;
/* Set the fill directions and the raster op */
blitter_regs_32[BLITTER_REG_CTRL >> 2] = (1 << 10) | (1 << 9) | (1 << 8) | 0xf0;
/* Launch the blitter operation */
asm volatile("":::"memory");
blitter_regs_32[BLITTER_REG_RUN >> 2] = 0x01;
}
The 'BLITTER_REG_XXX' comes from the MMSP2 manual. My code freeze the GP2X without displaying anything when I perform that
Code:
asm volatile ("":::"memory");
blitter_regs_32[BLITTER_REG_RUN] = 0x01;
What I missed ?
Last edited by a moderator: