Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 73 → Rev 74

/shark/trunk/drivers/svga/grx/glib.c
5,10 → 5,28
 
#define fontaddr 0xffa6eL /* indirizzo set caratteri */
 
unsigned char * flbaddr;
unsigned int bpr;
unsigned int height, width;
BYTE * flbaddr;
WORD bpr;
WORD height, width;
 
inline void memsetw(void *dst, unsigned int c, unsigned long int memdiv2)
{
__asm__ __volatile__("push %%edi
push %%eax
push %%ecx
movl %2, %%edi
cld
rep
stosw
pop %%ecx
pop %%eax
pop %%edi"
:
: "c" (memdiv2), "a" (c), "b" (dst));
 
}
 
 
static void circlepixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c)
{
grx_plot(sx + x, sy + y, c);
79,13 → 97,15
}
}
 
int grx_setbuffer(unsigned char *vbuf, unsigned int w, unsigned int h)
int grx_setbuffer(BYTE *vbuf, WORD w, WORD h)
{
 
//This functions are designed to work only whit 16 bpp
flbaddr = vbuf;
width = w;
height = h;
bpr = 4 * w;
bpr = 2 * w;
return 1;
105,14 → 125,14
 
void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
unsigned char * addr;
WORD dx, y;
BYTE * addr;
int dx, y;
addr = flbaddr + (x1 << 2) + bpr * y1;
dx = (x2 - x1 + 1);
addr = flbaddr + (x1 << 1) + bpr * y1;
dx = (x2 - x1 + 1) << 1;
 
for (y = y1; y <= y2; y++) {
memset((unsigned long int *)(addr),(DWORD)(color),dx);
memsetw(addr,color,(dx>>1));
addr += bpr;
}
}
119,39 → 139,40
 
void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
unsigned char * addr;
WORD dx, y;
BYTE * addr;
int dx, y;
addr = flbaddr + (x1 << 2) + bpr * y1;
dx = (x2 - x1);
addr = flbaddr + (x1 << 1) + bpr * y1;
dx = (x2 - x1) << 1;
 
memset((unsigned long int *)(addr),(DWORD)color,dx+2);
memsetw(addr,color,(dx>>1)+1);
addr += bpr;
 
for (y = y1 + 1; y <= y2 - 1; y++) {
*(unsigned long int *)addr = (DWORD)color;
*(unsigned long int *)(addr + (dx<<2)) = (DWORD)color;
*(WORD *)(addr) = (WORD)(color);
*(WORD *)(addr + dx) = (WORD)(color);
addr += bpr;
}
memset((unsigned long int *)(addr),(DWORD)(color),dx+2);
memsetw(addr,color,(dx>>1)+1);
}
 
void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg)
{
unsigned char * fp, * addr;
BYTE * fp;
BYTE * addr;
int r, c, bits;
 
addr = flbaddr;
while (*text) {
fp = (unsigned char *)(fontaddr + (8 * *(BYTE *)text));
fp = (BYTE *)(fontaddr + (8 * *(BYTE *)text));
for (r=0; r<8; r++) {
bits = *(unsigned char *)(fp++);
bits = *(BYTE *)(fp++);
for (c=0; c<8; c++)
if (bits & (0x80>>c))
*(unsigned long int *)(addr + (y + r) * bpr + ((x + c) << 2)) = (DWORD)fg;
*(WORD *)(addr + (y + r) * bpr + ((x + c) << 1)) = (WORD)(fg);
else
*(unsigned long int *)(addr + (y + r) * bpr + ((x + c) << 2)) = (DWORD)bg;
*(WORD *)(addr + (y + r) * bpr + ((x + c) << 1)) = (WORD)(bg);
}
text++;
x += 8;
161,7 → 182,7
void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
register int t, distance;
unsigned char * addr;
BYTE * addr;
int xerr=0, yerr=0, deltax, deltay;
int incx, incy;
 
191,7 → 212,7
distance = deltay;
 
for (t=0; t<=distance+1; t++) { /* draw the line */
*(unsigned long int *)(addr + y1 * bpr + (x1 << 2)) = (DWORD)color;
*(WORD *)(addr + y1 * bpr + (x1 << 1)) = (WORD)color;
xerr += deltax;
yerr += deltay;
if (xerr > distance) {
207,7 → 228,7
 
void grx_plot(WORD x, WORD y, DWORD color)
{
*(unsigned long int *)(flbaddr + y * bpr + (x << 2)) = (DWORD)color;
*(WORD *)(flbaddr + y * bpr + (x << 1)) = (WORD)color;
}
 
DWORD grx_getpixel(WORD x, WORD y)
214,7 → 235,7
{
DWORD rv;
 
(DWORD)rv = *(unsigned long int *)(flbaddr + y * bpr + (x << 2));
(DWORD)rv = *(WORD *)(flbaddr + y * bpr + (x << 1));
return rv;
}