Code Search for Developers
 
 
  

fblin32.c from The Open2x Project at Krugle


Show fblin32.c syntax highlighted

/*
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
 *
 * 32bpp Linear Video Driver for Microwindows
 *
 * Inspired from Ben Pfaff's BOGL <pfaffben@debian.org>
 *
 *  - godori <ghcstop>, www.aesop-embedded.org
 *    => Modified. 2001. 02. 11
 */

#include <assert.h>
#include <string.h>
#include "gfxdev.h"

/* Calc linelen and mmap size, return 0 on fail*/
static int
linear32_init(PSD psd)
{
   if (!psd->size) {
      psd->size = psd->yres * psd->linelen;
      /* convert linelen from byte to pixel len for bpp 16, 24, 32*/
      psd->linelen /= 4;
   }
   return 1;
}

/* Set pixel at x, y, to pixelval c*/
static void
linear32_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
{
   ADDR32   addr = psd->addr;

   assert (addr != 0);
   assert (x >= 0 && x < psd->xres);
   assert (y >= 0 && y < psd->yres);
   assert (c < psd->ncolors);
   
   x += psd->xoffset;
   y += psd->yoffset;
   

   addr[x + y * psd->linelen] = c;
}

/* Read pixel at x, y*/
static MWPIXELVAL
linear32_readpixel(PSD psd, MWCOORD x, MWCOORD y)
{
   ADDR32   addr = psd->addr;

   assert (addr != 0);
   assert (x >= 0 && x < psd->xres);
   assert (y >= 0 && y < psd->yres);
   
   x += psd->xoffset;
   y += psd->yoffset;
   

   return addr[x + y * psd->linelen];
}

/* Draw horizontal line from x1,y to x2,y including final point*/
static void
linear32_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
{
   ADDR32   addr = psd->addr;

   assert (addr != 0);
   assert (x1 >= 0 && x1 < psd->xres);
   assert (x2 >= 0 && x2 < psd->xres);
   assert (x2 >= x1);
   assert (y >= 0 && y < psd->yres);
   assert (c < psd->ncolors);

   x1 += psd->xoffset;
   x2 += psd->xoffset;
   y += psd->yoffset;


   addr += x1 + y * psd->linelen;
   //FIXME: memsetl(dst, c, x2-x1+1)?
   while(x1++ <= x2)
       *addr++ = c;
}

/* Draw a vertical line from x,y1 to x,y2 including final point*/
static void
linear32_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
{
   ADDR32   addr = psd->addr;
   int   linelen = psd->linelen;

   assert (addr != 0);
   assert (x >= 0 && x < psd->xres);
   assert (y1 >= 0 && y1 < psd->yres);
   assert (y2 >= 0 && y2 < psd->yres);
   assert (y2 >= y1);
   assert (c < psd->ncolors);


   x += psd->xoffset;
   y1 += psd->yoffset;
   y2 += psd->yoffset;


      while(y1++ <= y2) {
         *addr = c;
         addr += linelen;
      }
}


int set_sub_driver_32bpp(PSD psd)
{
	psd->Init         = linear32_init;
	psd->DrawPixel    = linear32_drawpixel;
	psd->ReadPixel    = linear32_readpixel;
	psd->DrawHorzLine = linear32_drawhorzline;
	psd->DrawVertLine = linear32_drawvertline;
	psd->FillRect     = gen_fillrect;
	
	return 0;
}




See more files for this project here

The Open2x Project

The Open2x project exists to provide an open source resource for the GP2X handheld console based on the MagicEyes MMSP2 processing platform and MP2520F SoC. The project hosts Linux kernel source for the GP2X, boot loader (U-Boot) source and more.

Project homepage: http://www.distant-earth.com/open2x
Programming language(s): Assembly,C,C++
License: other

  Makefile
  fblin16.c
  fblin24.c
  fblin32.c
  fbs.h
  fontdisp.h
  fontout.c
  gfxdev.h
  gfxfontext.c
  gfxfontload.c
  gfxfontout.c
  gfxtype.h
  gulim_96_10_eng.c
  gulim_96_10_han.c
  main.c
  scr_fb.c