示例#1
0
void drawLine4(int r0, int c0, int r1, int c1, u16 color) {
#ifdef _DEBUG
/*
	fprintf(debug, "drawLine(r0=//d, c0=//d, r1=//d, c1=//d, color=//X)\n",
			r0, c0, r1, c1, color);
	fflush(debug);
*/
#endif
	int w = c1 - c0;
	int h = r1 - r0;
	double ratio;
	int c, r;
	int upright = 1;
	if(fabs(h) > fabs(w)) {
		upright = 0;
		swap(&r0, &c0);
		swap(&r1, &c1);
		swap(&w, &h);
	}
	if( c0 > c1 ) {
		swap(&r0, &r1);
		swap(&c0, &c1);
	}
	ratio = ((double) h) / w;
	for(c = c0; c < c1; c++) {
		r = r0 + (c-c0) * ratio;
		if(upright) setPixel4(r, c, color);
		else setPixel4(c, r, color);
	}
}
void drawRect4(int row, int col, int height, int width, unsigned char colorIndex)
{
	unsigned short pixels = colorIndex << 8 | colorIndex;

	int r;
	for(r = 0; r < height; r++)
	{
		if(col % 2 == 0) // even starting col
		{
			DMANow(3, &pixels, &videoBuffer[OFFSET(row + r, col/2, SCREENWIDTH/2)], (width/2) | DMA_SOURCE_FIXED);	
			if(width % 2 == 1) // if width is odd
			{
				setPixel4(row+r, col+width - 1, colorIndex);
			}
		}
		else // old starting col
		{
			setPixel4(row+r, col, colorIndex);

			if(width % 2 == 1) // if width is odd
			{
				DMANow(3, &pixels, &videoBuffer[OFFSET(row + r, (col+1)/2, SCREENWIDTH/2)], (width/2) | DMA_SOURCE_FIXED);
			}
			else  // width is even
			{
				DMANow(3, &pixels, &videoBuffer[OFFSET(row + r, (col+1)/2, SCREENWIDTH/2)], ((width/2)-1) | DMA_SOURCE_FIXED);
				setPixel4(row+r, col+width - 1, colorIndex);
			}
		}
	}
	
}
示例#3
0
void DMALine(int r, int c, int w, byte clr) {
#ifndef _DEBUG
	volatile u16 color = clr << 8 | clr;
	if(r >= 0 && r < SCREEN_HEIGHT) {
		if(c < 0) {
			w += c;
			c = 0;
		}
		if((c+w) >= SCREEN_WIDTH) {
			w -= SCREEN_WIDTH - (w + c);
		}
		if(w > 0 && c & 1) {
			setPixel4(r, c++, clr);
			w--;
		}
		if(w > 0 && w & 1)
			setPixel4(r, (c+ (w--) -1), clr);
		if(w > 0) {
			DMA_MEMFILL3_SHRT(videoBuffer + OFFSET(r, c)/2,
				&color,
				w/2);
		}
	}
#else
	fprintf(debug,"DMALine(%d, %d, %d, %d)\n",
			r, c, w, clr);
#endif
}
示例#4
0
文件: mylib.c 项目: evanyui/megamanX
void drawHollowRect4(int row, int col, int height, int width, u8 index) 
{
	int c, r;
	for(c=0; c<width; c++)
	{
		setPixel4(row, col+c, index);
		setPixel4(row+height, col+c, index);
	}
	for(r=0; r<height; r++)
	{
		setPixel4(row+r, col, index);
		setPixel4(row+r, col+width, index);
	}
}
示例#5
0
void
drawX4(int r, int c, u8 palette)
{
  setPixel4(r-2,c-2,palette);
  setPixel4(r+2,c-2,palette);
  setPixel4(r-2,c+2,palette);
  setPixel4(r+2,c+2,palette);
  setPixel4(r-1,c-1,palette);
  setPixel4(r+1,c-1,palette);
  setPixel4(r-1,c+1,palette);
  setPixel4(r+1,c+1,palette);
}
示例#6
0
文件: draw.c 项目: zjhzyyk/gba-pacman
void drawRect(u16 row, u16 col, u16 height, u16 width, u8 index)
{
	u16 r,c;
	for(r=0; r<height; r++)
	{
		for(c=0; c<width; c++)
		{
			setPixel4(row+r, col+c, index);
		}
	}
}
示例#7
0
文件: text.c 项目: 384579283/cs2110
void drawChar(int row, int col, char ch, unsigned short color)
{
	for(int r=0; r<8; r++)
	{
		for(int c=0; c<6; c++)
		{
			if(fontdata_6x8[OFFSET(r,c,6) + ch*48])
			{
				setPixel4(row+r, col+c, color);
			}
		}
	}
}
示例#8
0
文件: text.c 项目: evanyui/megamanX
void drawChar4(int row, int col, char ch, u8 index)
{
	int r,c;
	for(r=0; r<8; r++)
	{
		for(c=0; c<6; c++)
		{
			if(fontdata_6x8[(r*6+c)+(48*ch)] == 1)
			{
				setPixel4(row+r, col+c, index);
			}
		}
	}
}
示例#9
0
void drawChar4(int row, int col, char ch, unsigned char colorIndex)
{
	// COMPLETE THIS FUNCTION ! ! !
	int r, c;
    for(r=0; r<8; r++)
    {
        for(c=0; c<6; c++)
        {
            if(fontdata_6x8[ch*6*8+r*6+c])
            {
                setPixel4(row+r, col+c, colorIndex);
            }
        }
    }
}
示例#10
0
文件: text.c 项目: jennifer-ma/code
void drawChar4(int row, int col, char ch, unsigned char index)
{
    int r,c;
    for(r=0; r<8; r++)
    {
        for(c=0; c< 6; c++)
        {
            if(fontdata_6x8[OFFSET(r, c, 6)+48*ch])
            {
                setPixel4(r+row, c+col, index);
            }
        }
    }
    
}
示例#11
0
文件: text.c 项目: gstache/Ronin-GBA
void drawChar4(int row, int col, char ch, volatile unsigned char colorIndex)
{
	// TODO implement this function
    volatile unsigned short pixels = colorIndex << 8 | colorIndex;
    row = row & (~1);
    col = col & (~1);
    int r, c;
    for(r=0; r<8; r++)
    {
        for(c=0; c<6; c++)
        {
            if(fontdata_6x8[ch*6*8+r*6+c])
            {
                setPixel4(row+r, col+c, pixels);
            }
        }
    }
}
示例#12
0
void drawLineMode4(int row, int col, int width, int index) {
 	int c;
	for(c = 0; c < width; c++) {
		setPixel4 ( row, c + col, index);
	}
}
示例#13
0
void plot4points4(int cy, int cx, int y, int x, u16 color) {
	setPixel4(cx + x, cy + y, color);
	if (x != 0) setPixel4(cx - x, cy + y, color);
	if (y != 0) setPixel4(cx + x, cy - y, color);
	if (x != 0 && y != 0) setPixel4(cx - x, cy - y, color);
}