From 866f0ad8030ea2ceea22a4d61e6ff0006546c3fa Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 13 May 2003 12:05:12 +0000 Subject: Here we go --- Gfx.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 Gfx.c (limited to 'Gfx.c') diff --git a/Gfx.c b/Gfx.c new file mode 100755 index 0000000..1145f9a --- /dev/null +++ b/Gfx.c @@ -0,0 +1,65 @@ +#include "Gfx.h" +#include "Kullers.h" + +static void *bitmap = (void*)0; +unsigned long g_width, g_height; +unsigned long minx, miny, maxx, maxy; + +void Gfx_init( void *offscreen, int width, int height ) { + maxx = g_width = width; + maxy = g_height = height; + bitmap = offscreen; + minx = miny = 0; +} + +void Gfx_destroy( void ) { +// if( bitmap ) +// free( bitmap ); +} + +void Gfx_clear( void ) { + unsigned long *dest = ((unsigned long *)bitmap) + miny * g_width + minx; + int nochy = maxy - miny; + + while( nochy-- ) { + memset( dest, 0, (maxx - minx) << 2); + dest += g_width; + } + + minx = g_width; miny = g_height; + maxx = 0; maxy = 0; +} + +int getkulleroff( int radius ) { + int sum = 0; + while( --radius>0 ) + sum += radius*radius; + return sum; +} + +void Gfx_kuller( int x, int y, int radius, unsigned long r, unsigned long g, unsigned long b ) { + unsigned long *dest = ((unsigned long *)bitmap) + y * g_width + x; + unsigned char *src = Kullers + getkulleroff( radius ) - 1; + int xoffs = g_width - radius; + int nochy = radius; + + if( minx > x ) minx = x; + if( miny > y ) miny = y; + if( maxx < x + radius ) maxx = x + radius; + if( maxy < y + radius ) maxy = y + radius; + + while( nochy-- >0 ) { + int nochx = radius; + while( nochx-- >0 ) { + if( *(++src) ) { + int this_r = ((r * (int)*src) >> 8); + int this_g = ((g * (int)*src) >> 8); + int this_b = ((b * (int)*src) >> 8); + *(dest++) = (this_r<<16) | (this_g<<8) | this_b; + } else { + dest++; + } + } + dest += xoffs; + } +} -- cgit v1.2.3