📄 rndr_gu1.c
字号:
WRITE_REG16(GP_RASTER_MODE, 0x00CC);
WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1);
/* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */
GFX_WAIT_PENDING;
WRITE_REG16(GP_HEIGHT, height);
WRITE_REG16(GP_RASTER_MODE, 0x10C6);
WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF);
/* REPEAT UNTIL FINISHED WITH RECTANGLE */
/* Perform BLT in vertical sections, as wide as the BLT buffer allows. */
/* Hardware does not split the operations, so software must do it to */
/* avoid large scanlines that would overflow the BLT buffers. */
while(width > 0)
{
/* CHECK WIDTH OF CURRENT SECTION */
if (width > buffer_width) section = buffer_width;
else section = width;
/* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */
GFX_WAIT_PENDING;
WRITE_REG16(GP_SRC_YCOOR, srcy);
WRITE_REG16(GP_DST_YCOOR, dsty);
WRITE_REG16(GP_WIDTH, section);
/* CHECK X DIRECTION */
/* Again, this must be done in software, and can be removed if the */
/* display driver knows that the BLT buffers will always be large */
/* enough to contain an entire scanline of a screen to screen BLT. */
if (dstx > srcx)
{
/* NEGATIVE X DIRECTION */
/* Still positive X direction within the section. */
srcx -= section;
dstx -= section;
WRITE_REG16(GP_SRC_XCOOR, srcx);
WRITE_REG16(GP_DST_XCOOR, dstx);
WRITE_REG16(GP_BLIT_MODE, blit_mode);
}
else
{
/* POSITIVE X DIRECTION */
WRITE_REG16(GP_SRC_XCOOR, srcx);
WRITE_REG16(GP_DST_XCOOR, dstx);
WRITE_REG16(GP_BLIT_MODE, blit_mode);
dstx += section;
srcx += section;
}
width -= section;
}
}
/*
//----------------------------------------------------------------------------
// COLOR BITMAP TO SCREEN BLT
//
// This routine transfers color bitmap data to the screen. For most cases,
// when the ROP is SRCCOPY, it may be faster to write a separate routine that
// copies the data to the frame buffer directly. This routine should be
// used when the ROP requires destination data.
//
// Transparency is handled by another routine.
//
// SRCX X offset within source bitmap
// SRCY Y offset within source bitmap
// DSTX screen X position to render data
// DSTY screen Y position to render data
// WIDTH width of rectangle, in pixels
// HEIGHT height of rectangle, in scanlines
// *DATA pointer to bitmap data
// PITCH pitch of bitmap data (bytes between scanlines)
//----------------------------------------------------------------------------
*/
#if GFX_2DACCEL_DYNAMIC
void gu1_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy,
unsigned short dstx, unsigned short dsty, unsigned short width,
unsigned short height, unsigned char *data, long pitch)
#else
void gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy,
unsigned short dstx, unsigned short dsty, unsigned short width,
unsigned short height, unsigned char *data, long pitch)
#endif
{
unsigned short section, buffer_width;
unsigned short blit_mode = BM_READ_SRC_BB0;
unsigned short line_srcx, line_dstx, line_width;
unsigned short i;
long offset;
/* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */
if (GFXusesDstData) blit_mode |= BM_READ_DST_FB1;
/* CHECK SIZE OF BLT BUFFER */
buffer_width = GFXbufferWidthPixels;
/* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
/* Write the registers that do not change for each section. */
GFX_WAIT_PENDING;
WRITE_REG16(GP_HEIGHT, 1);
/* REPEAT FOR EACH SCANLINE */
offset = (unsigned long) srcy * (long)pitch;
while(height > 0)
{
line_width = width;
line_srcx = srcx;
line_dstx = dstx;
while(line_width > 0)
{
/* CHECK WIDTH OF CURRENT SECTION */
if (line_width > buffer_width) section = buffer_width;
else section = line_width;
/* TRANSFER SCANLINE OF BITMAP DATA TO BLT BUFFER 0 */
/* Need to wait for BS_PIPELINE_BUSY to make sure that the */
/* data in BB0 for the previous scanline is no longer used. */
/* This can be heavily optimized to not do a byte at a time. */
GFX_WAIT_BUSY;
if (GFXbpp > 8)
{
#ifdef DUROPTI
unsigned short *data16 = (unsigned short *)&data[line_srcx+offset];
unsigned long *data32=0x0;
unsigned short ScPad = GFXbb0Base;
if(section >=2 ){ //32 bit
int width_words = section / 2;
data32 = (unsigned long *)data16;
for (i = 0; i < width_words; i++)
{
WRITE_REG32(ScPad, data32[i]);
ScPad += 4;
}
data16 = (unsigned short *)&data32[i];
}
for (i = 0; i < (section & 0x1); i++)
{
WRITE_REG16(ScPad, data16[i]);
ScPad +=2;
}
#else
for (i = 0; i < section; i++)
{
WRITE_REG16(GFXbb0Base+(i<<1),
*((unsigned short *) &data[offset+((line_srcx+i)<<1)]));
}
#endif
}
else
{
#ifdef DUROPTI
unsigned char *data8 = &data[line_srcx+offset];
unsigned long *data32=0x0;
unsigned short ScPad = GFXbb0Base;
if(section >=4 ){ //32 bit
int width_words = section / 4;
data32 = (unsigned long *)data8;
for (i = 0; i < width_words; i++)
{
WRITE_REG32(ScPad, data32[i]);
ScPad += 4;
}
data8 = (unsigned char *)&data32[i];
}
for (i = 0; i < (section & 0x3); i++)
{
WRITE_REG8(ScPad, data8[i]);
ScPad ++;
}
#else
for (i = 0; i < section; i++)
{
WRITE_REG8(GFXbb0Base+i, data[line_srcx+offset+i]);
}
#endif
}
/* RENDER FROM BB0 TO FRAME BUFFER */
GFX_WAIT_PENDING;
WRITE_REG16(GP_DST_XCOOR, line_dstx);
WRITE_REG16(GP_DST_YCOOR, dsty);
WRITE_REG16(GP_WIDTH, section);
WRITE_REG16(GP_BLIT_MODE, blit_mode);
line_width -= section;
line_dstx += section;
line_srcx += section;
}
height--;
dsty++;
offset += pitch;
}
}
/*
//----------------------------------------------------------------------------
// COLOR BITMAP TO SCREEN TRANSPARENT BLT
//
// This routine transfers color bitmap data to the screen with transparency.
// The transparent color is specified. The only supported ROP is SRCCOPY,
// meaning that transparency cannot be applied if the ROP requires
// destination data (this is a hardware restriction).
//
// SRCX X offset within source bitmap
// SRCY Y offset within source bitmap
// DSTX screen X position to render data
// DSTY screen Y position to render data
// WIDTH width of rectangle, in pixels
// HEIGHT height of rectangle, in scanlines
// *DATA pointer to bitmap data
// PITCH pitch of bitmap data (bytes between scanlines)
// COLOR transparent color
//----------------------------------------------------------------------------
*/
#if GFX_2DACCEL_DYNAMIC
void gu1_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy,
unsigned short dstx, unsigned short dsty, unsigned short width,
unsigned short height, unsigned char *data, long pitch,
unsigned long color)
#else
void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy,
unsigned short dstx, unsigned short dsty, unsigned short width,
unsigned short height, unsigned char *data, long pitch,
unsigned long color)
#endif
{
unsigned short section, buffer_width;
unsigned short blit_mode = BM_READ_SRC_BB0;
unsigned short line_srcx, line_dstx, line_width;
unsigned short i;
long offset;
/* CHECK SIZE OF BLT BUFFER */
buffer_width = GFXbufferWidthPixels;
/* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */
if (GFXbpp == 8)
{
color &= 0x00FF;
color |= (color << 8);
}
color = (color & 0x0000FFFF) | (color << 16);
/* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */
/* Need to make sure any previous BLT using BB1 is complete. */
/* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */
GFX_WAIT_BUSY;
WRITE_REG32(GFXbb1Base, color);
/* DO BOGUS BLT TO LATCH DATA FROM BB1 */
/* Already know graphics pipeline is idle. */
/* Only need to latch data into the holding registers for the current */
/* data from BB1. A 1 pixel wide BLT will suffice. */
WRITE_REG32(GP_DST_XCOOR, 0);
WRITE_REG32(GP_SRC_XCOOR, 0);
WRITE_REG32(GP_WIDTH, 0x00010001);
WRITE_REG16(GP_RASTER_MODE, 0x00CC);
WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1);
/* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */
/* Write the registers that do not change for each section. */
GFX_WAIT_PENDING;
WRITE_REG16(GP_HEIGHT, 1);
WRITE_REG16(GP_RASTER_MODE, 0x10C6);
WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF);
/* CALCULATE OFFSET INTO BITMAP DATA */
offset = (unsigned long) srcy * (long)pitch;
/* REPEAT FOR EACH SCANLINE */
while(height > 0)
{
line_width = width;
line_srcx = srcx;
line_dstx = dstx;
while(line_width > 0)
{
/* CHECK WIDTH OF CURRENT SECTION */
if (line_width > buffer_width) section = buffer_width;
else section = line_width;
/* TRANSFER SCANLINE OF BITMAP DATA TO BLT BUFFER 0 */
/* Need to wait for BS_PIPELINE_BUSY to make sure that the */
/* data in BB0 for the previous scanline is no longer used. */
/* This can be heavily optimized to not do a byte at a time. */
GFX_WAIT_BUSY;
if (GFXbpp > 8)
{
#ifdef DUROPTI
unsigned short *data16 = (unsigned short *)&data[line_srcx+offset];
unsigned long *data32=0x0;
unsigned short ScPad = GFXbb0Base;
if(section >=2 ){ //32 bit
int width_words = section / 2;
data32 = (unsigned long *)data16;
for (i = 0; i < width_words; i++)
{
WRITE_REG32(ScPad, data32[i]);
ScPad += 4;
}
data16 = (unsigned short *)&data32[i];
}
for (i = 0; i < (section & 0x1); i++)
{
WRITE_REG16(ScPad, data16[i]);
ScPad +=2;
}
#else
for (i = 0; i < section; i++)
{
WRITE_REG16(GFXbb0Base+(i<<1),
*((unsigned short *) &data[offset+((line_srcx+i)<<1)]));
}
#endif
}
else
{
#ifdef DUROPTI
unsigned char *data8 = &data[line_srcx+offset];
unsigned long *data32=0x0;
unsigned short ScPad = GFXbb0Base;
if(section >=4 ){ //32 bit
int width_words = section / 4;
data32 = (unsigned long *)data8;
for (i = 0; i < width_words; i++)
{
WRITE_REG32(ScPad, data32[i]);
ScPad += 4;
}
data8 = (unsigned char *)&data32[i];
}
for (i = 0; i < (section & 0x3); i++)
{
WRITE_REG8(ScPad, data8[i]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -