# HG changeset patch # User nenolod # Date 1162534745 28800 # Node ID a7c8234781804211c4572f009172b4945ae796bf # Parent 6d5f164a8719b9c797c76d2819e2cb0e28a781bc [svn] - add fast linedrawing code diff -r 6d5f164a8719 -r a7c823478180 ChangeLog --- a/ChangeLog Thu Nov 02 21:44:14 2006 -0800 +++ b/ChangeLog Thu Nov 02 22:19:05 2006 -0800 @@ -1,3 +1,11 @@ +2006-11-03 05:44:14 +0000 William Pitcock + revision [382] + - fix warning (oops) + + trunk/src/paranormal/paranormal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + 2006-11-03 05:43:22 +0000 William Pitcock revision [380] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff diff -r 6d5f164a8719 -r a7c823478180 src/paranormal/Makefile --- a/src/paranormal/Makefile Thu Nov 02 21:44:14 2006 -0800 +++ b/src/paranormal/Makefile Thu Nov 02 22:19:05 2006 -0800 @@ -16,6 +16,7 @@ cfg.c \ cmaps.c \ containers.c \ + drawing.c \ freq.c \ general.c \ misc.c \ diff -r 6d5f164a8719 -r a7c823478180 src/paranormal/drawing.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paranormal/drawing.c Thu Nov 02 22:19:05 2006 -0800 @@ -0,0 +1,74 @@ +#include "paranormal.h" +#include "actuators.h" +#include "pn_utils.h" + +extern SDL_Surface *screen; + +void +pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value) +{ + gint x0 = _x0; + gint y0 = _y0; + gint x1 = _x1; + gint y1 = _y1; + + gint dy = y1 - y0; + gint dx = x1 - x0; + gint stepx, stepy; + gint fraction; + + if (dy < 0) + { + dy = -dy; + stepy = -(screen->pitch >> 2); + } + else + { + stepy = screen->pitch>>2; + } + if (dx < 0) + { + dx = -dx; + stepx = -1; + } + else + { + stepx = 1; + } + dy <<= 1; + dx <<= 1; + + y0 *= screen->pitch>>2; + y1 *= screen->pitch>>2; + pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; + if (dx > dy) + { + fraction = dy - (dx >> 1); + while (x0 != x1) + { + if (fraction >= 0) + { + y0 += stepy; + fraction -= dx; + } + x0 += stepx; + fraction += dy; + pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; + } + } + else + { + fraction = dx - (dy >> 1); + while (y0 != y1) + { + if (fraction >= 0) + { + x0 += stepx; + fraction -= dy; + } + y0 += stepy; + fraction += dx; + pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; + } + } +} diff -r 6d5f164a8719 -r a7c823478180 src/paranormal/paranormal.c --- a/src/paranormal/paranormal.c Thu Nov 02 21:44:14 2006 -0800 +++ b/src/paranormal/paranormal.c Thu Nov 02 22:19:05 2006 -0800 @@ -19,7 +19,7 @@ #include "actuators.h" /* SDL stuffs */ -static SDL_Surface *screen; +SDL_Surface *screen; /* Globals */ struct pn_rc *pn_rc;