Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 110 → Rev 106

/shark/trunk/drivers/svga/include/drivers/glib.h
File deleted
/shark/trunk/drivers/svga/include/drivers/vga.h
File deleted
/shark/trunk/drivers/svga/glib.c
File deleted
/shark/trunk/drivers/svga/makefile
11,12 → 11,10
 
OBJS_PATH = $(BASE)/drivers/svga
 
OTHERINCL += -I./include/
 
MODULES = timing.o vgaregs.o interface.o accel.o modetab.o interrupt.o\
vgapci.o vga_helper.o nv3.o vga.o vgadrv.o vgaio.o vgapal.o\
vgaclear.o vgadraw.o vgaaccel.o vgaline.o icd2061a.o\
glib.o vgammvgaio.o vgarelvgaio.o savage.o r128.o
./grx/glib.o vgammvgaio.o vgarelvgaio.o savage.o r128.o
RAMDAC = ramdac.o normal.o attdacs.o sierra.o vgamisc.o\
icw.o s3dacs.o IBMRGB52x.o ics_gendac.o
 
/shark/trunk/drivers/svga/grx/glib.h
0,0 → 1,73
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/**
------------
CVS : $Id: glib.h,v 1.3 2003-03-13 13:46:08 pj Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2003-03-13 13:46:08 $
------------
 
**/
 
/*
* Copyright (C) 2000 Luca Abeni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#ifndef __GLIB_H__
#define __GLIB_H__
 
#include <ll/sys/types.h>
#include "ll/sys/cdefs.h"
 
__BEGIN_DECLS
 
int grx_setbuffer(BYTE *vbuf,WORD w, WORD h);
 
void grx_plot(WORD x, WORD y, DWORD color);
DWORD grx_getpixel(WORD x, WORD y);
//void grx_getimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf);
//void grx_putimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf);
void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color);
void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color);
void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color);
void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg);
void grx_circle(WORD x, WORD y, WORD r, DWORD col);
void grx_disc(WORD x, WORD y, WORD r, DWORD col);
void grx_clear(DWORD color);
__END_DECLS
#endif
/shark/trunk/drivers/svga/grx/glib.c
0,0 → 1,241
#include "glib.h"
#include <stdlib.h>
 
#include "../vga.h"
 
#define fontaddr 0xffa6eL /* indirizzo set caratteri */
 
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);
grx_plot(sx - x, sy + y, c);
grx_plot(sx + x, sy - y, c);
grx_plot(sx - x, sy - y, c);
grx_plot(sx + y, sy + x, c);
grx_plot(sx - y, sy + x, c);
grx_plot(sx + y, sy - x, c);
grx_plot(sx - y, sy - x, c);
}
 
void grx_circle(WORD sx, WORD sy, WORD r, DWORD c)
{
int x, y, d;
if (r < 1) {
grx_plot(sx, sy, c);
return;
}
x = 0;
y = r;
d = 1 - r;
circlepixels(x, y, sx, sy, c);
while (x < y) {
if (d < 0)
d += x * 2 + 3;
else {
d += x * 2 - y * 2 + 5;
y--;
}
x++;
circlepixels(x, y, sx, sy, c);
}
}
 
/* grx_disc by Massy */
 
static __inline__ void discpixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c)
{
grx_line(sx + x, sy + y, sx + x, sy - y, c);
grx_line(sx - x, sy + y, sx - x, sy - y, c);
grx_line(sx + y, sy + x, sx + y, sy - x , c);
grx_line(sx - y, sy + x, sx - y, sy - x , c);
}
 
void grx_disc(WORD sx, WORD sy, WORD r, DWORD c)
{
int x, y, d;
if (r < 1) {
grx_plot(sx, sy, c);
return;
}
x = 0;
y = r;
d = 1 - r;
discpixels(x, y, sx, sy, c);
while (x < y) {
if (d < 0)
d += x * 2 + 3;
else {
d += x * 2 - y * 2 + 5;
y--;
}
x++;
discpixels(x, y, sx, sy, c);
}
}
 
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 = 2 * w;
return 1;
}
 
void grx_clear(DWORD color)
{
 
grx_box(0, 0, width, height, color);
 
}
 
void grx_putimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf)
{
}
 
void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
BYTE * addr;
int dx, y;
addr = flbaddr + (x1 << 1) + bpr * y1;
dx = (x2 - x1 + 1) << 1;
 
for (y = y1; y <= y2; y++) {
memsetw(addr,color,(dx>>1));
addr += bpr;
}
}
 
void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
BYTE * addr;
int dx, y;
addr = flbaddr + (x1 << 1) + bpr * y1;
dx = (x2 - x1) << 1;
 
memsetw(addr,color,(dx>>1)+1);
addr += bpr;
 
for (y = y1 + 1; y <= y2 - 1; y++) {
*(WORD *)(addr) = (WORD)(color);
*(WORD *)(addr + dx) = (WORD)(color);
addr += bpr;
}
memsetw(addr,color,(dx>>1)+1);
}
 
void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg)
{
BYTE * fp;
BYTE * addr;
int r, c, bits;
 
addr = flbaddr;
while (*text) {
fp = (BYTE *)(fontaddr + (8 * *(BYTE *)text));
for (r=0; r<8; r++) {
bits = *(BYTE *)(fp++);
for (c=0; c<8; c++)
if (bits & (0x80>>c))
*(WORD *)(addr + (y + r) * bpr + ((x + c) << 1)) = (WORD)(fg);
else
*(WORD *)(addr + (y + r) * bpr + ((x + c) << 1)) = (WORD)(bg);
}
text++;
x += 8;
}
}
 
void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
{
register int t, distance;
BYTE * addr;
int xerr=0, yerr=0, deltax, deltay;
int incx, incy;
 
addr = flbaddr;;
deltax = x2 - x1; /* compute both distances */
deltay = y2 - y1;
 
if (deltax > 0) /* compute increments */
incx = 1;
else if (deltax == 0)
incx = 0;
else
incx = -1;
 
if (deltay > 0)
incy = 1;
else if (deltay == 0)
incy = 0;
else
incy = -1;
 
deltax = abs(deltax); /* determine greater distance */
deltay = abs(deltay);
if (deltax > deltay)
distance = deltax;
else
distance = deltay;
 
for (t=0; t<=distance+1; t++) { /* draw the line */
*(WORD *)(addr + y1 * bpr + (x1 << 1)) = (WORD)color;
xerr += deltax;
yerr += deltay;
if (xerr > distance) {
xerr -= distance;
x1 += incx;
}
if (yerr > distance) {
yerr -= distance;
y1 += incy;
}
}
}
 
void grx_plot(WORD x, WORD y, DWORD color)
{
*(WORD *)(flbaddr + y * bpr + (x << 1)) = (WORD)color;
}
 
DWORD grx_getpixel(WORD x, WORD y)
{
DWORD rv;
 
(DWORD)rv = *(WORD *)(flbaddr + y * bpr + (x << 1));
return rv;
}
 
/shark/trunk/drivers/svga/vga.h
11,7 → 11,7
 
#include <sys/types.h>
#include <sys/time.h>
#include <drivers/glib.h>
#include <drivers/grxsvga/glib.h>
#include <kernel/log.h>
 
#include "ll/sys/cdefs.h"
/shark/trunk/drivers/grx/include/drivers/gd.h
File deleted
/shark/trunk/drivers/grx/include/drivers/glib.h
File deleted
/shark/trunk/drivers/grx/include/drivers/comp.h
File deleted
/shark/trunk/drivers/grx/makefile
16,7 → 16,7
 
#vpath %.c drivers drawfun .
 
OTHERINCL = -I./include/
#OTHERINCL = -I$(BASE)/include/drivers
 
include $(BASE)/config/lib.mk