[Tux4kids-commits] r518 - in tuxmath/trunk: doc src

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Sat Jun 14 19:13:07 UTC 2008


Author: dbruce-guest
Date: 2008-06-14 19:13:05 +0000 (Sat, 14 Jun 2008)
New Revision: 518

Added:
   tuxmath/trunk/src/compiler.h
Removed:
   tuxmath/trunk/src/pixels.o
Modified:
   tuxmath/trunk/doc/changelog
   tuxmath/trunk/src/Makefile.am
   tuxmath/trunk/src/Makefile.in
   tuxmath/trunk/src/SDL_extras.c
   tuxmath/trunk/src/game.c
   tuxmath/trunk/src/loaders.c
   tuxmath/trunk/src/pixels.c
   tuxmath/trunk/src/titlescreen.h
   tuxmath/trunk/src/tuxmath.h
Log:
Fix of zoom() and getpixel/putpixel functions from TuxPaint - compiler.h added, pixels.c its own file now.



Modified: tuxmath/trunk/doc/changelog
===================================================================
--- tuxmath/trunk/doc/changelog	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/doc/changelog	2008-06-14 19:13:05 UTC (rev 518)
@@ -1,3 +1,14 @@
+2008.June.14 (svn.debian.org/tux4kids - revision 518)
+      Graphics:
+        Got zoom() working - made pixels.c its own file instead of having
+        putpixel??() and getpixel??() in SDL_extras.c. (basically, the
+        compiler.h file from TuxPaint was needed. Also added LoadBkgd() 
+        wrapper function for IMG_Load() that automatically rescales image
+        to screen size - should use this as replacement wherever backgrounds
+        need to be drawn.
+
+      David Bruce <davidstuartbruce at gmail.com>
+
 2008.April-May (svn.debian.org/tux4kids - revision 501)
 Version 1.6.3
 	Build:

Modified: tuxmath/trunk/src/Makefile.am
===================================================================
--- tuxmath/trunk/src/Makefile.am	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/Makefile.am	2008-06-14 19:13:05 UTC (rev 518)
@@ -36,7 +36,8 @@
 	ConvertUTF.c	\
 	SDL_extras.c	\
 	lessons.c	\
-	scandir.c
+	scandir.c	\
+	pixels.c
 
 TuxMath_SOURCES  = $(tuxmath_SOURCES) tuxmathrc.rc
 

Modified: tuxmath/trunk/src/Makefile.in
===================================================================
--- tuxmath/trunk/src/Makefile.in	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/Makefile.in	2008-06-14 19:13:05 UTC (rev 518)
@@ -71,7 +71,7 @@
 	credits.$(OBJEXT) highscore.$(OBJEXT) loaders.$(OBJEXT) \
 	audio.$(OBJEXT) mathcards.$(OBJEXT) fileops.$(OBJEXT) \
 	ConvertUTF.$(OBJEXT) SDL_extras.$(OBJEXT) lessons.$(OBJEXT) \
-	scandir.$(OBJEXT)
+	scandir.$(OBJEXT) pixels.$(OBJEXT)
 am_TuxMath_OBJECTS = $(am__objects_1)
 TuxMath_OBJECTS = $(am_TuxMath_OBJECTS)
 TuxMath_LDADD = $(LDADD)
@@ -81,7 +81,7 @@
 	credits.$(OBJEXT) highscore.$(OBJEXT) loaders.$(OBJEXT) \
 	audio.$(OBJEXT) mathcards.$(OBJEXT) fileops.$(OBJEXT) \
 	ConvertUTF.$(OBJEXT) SDL_extras.$(OBJEXT) lessons.$(OBJEXT) \
-	scandir.$(OBJEXT)
+	scandir.$(OBJEXT) pixels.$(OBJEXT)
 tuxmath_OBJECTS = $(am_tuxmath_OBJECTS)
 tuxmath_LDADD = $(LDADD)
 tuxmath_DEPENDENCIES =
@@ -278,7 +278,8 @@
 	ConvertUTF.c	\
 	SDL_extras.c	\
 	lessons.c	\
-	scandir.c
+	scandir.c	\
+	pixels.c
 
 TuxMath_SOURCES = $(tuxmath_SOURCES) tuxmathrc.rc
 tuxmathadmin_SOURCES = tuxmathadmin.c
@@ -383,6 +384,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/loaders.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mathcards.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/options.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pixels.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/scandir.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/setup.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/titlescreen.Po at am__quote@

Modified: tuxmath/trunk/src/SDL_extras.c
===================================================================
--- tuxmath/trunk/src/SDL_extras.c	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/SDL_extras.c	2008-06-14 19:13:05 UTC (rev 518)
@@ -9,6 +9,7 @@
 * Copyright: GPL v3 or later
 *
 */
+#include <math.h>
 
 #include "SDL_extras.h"
 #include "tuxmath.h"
@@ -520,23 +521,30 @@
    Based on code from: http://www.codeproject.com/cs/media/imageprocessing4.asp
    copyright 2002 Christian Graus */
 
-SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h)
+SDL_Surface* zoom(SDL_Surface* src, int new_w, int new_h)
 {
-  SDL_Surface * s;
-  void (*putpixel) (SDL_Surface *, int, int, Uint32);
-  Uint32(*getpixel) (SDL_Surface *, int, int) =
-    getpixels[src->format->BytesPerPixel];
+  SDL_Surface* s;
+
+  /* These function pointers will point to the appropriate */
+  /* putpixel() and getpixel() variants to be used in the  */
+  /* current colorspace:                                   */
+  void (*putpixel) (SDL_Surface*, int, int, Uint32);
+  Uint32(*getpixel) (SDL_Surface*, int, int);
+ 
   float xscale, yscale;
   int x, y;
-  float floor_x, ceil_x, floor_y, ceil_y, fraction_x, fraction_y,
-    one_minus_x, one_minus_y;
+  int floor_x, ceil_x,
+        floor_y, ceil_y;
+  float fraction_x, fraction_y,
+        one_minus_x, one_minus_y;
   float n1, n2;
-  float r1, g1, b1, a1;
-  float r2, g2, b2, a2;
-  float r3, g3, b3, a3;
-  float r4, g4, b4, a4;
+  Uint8 r1, g1, b1, a1;
+  Uint8 r2, g2, b2, a2;
+  Uint8 r3, g3, b3, a3;
+  Uint8 r4, g4, b4, a4;
   Uint8 r, g, b, a;
 
+  tmdprintf("\nEntering zoom():\n");
 
   /* Create surface for zoom: */
 
@@ -547,20 +555,26 @@
                            src->format->Bmask,
                            src->format->Amask);
 
-
   if (s == NULL)
   {
     fprintf(stderr, "\nError: Can't build zoom surface\n"
 	    "The Simple DirectMedia Layer error that occurred was:\n"
 	    "%s\n\n", SDL_GetError());
-
-    cleanup();
-    exit(1);
+    return NULL;
+//    cleanup();
+//    exit(1);
   }
 
+  tmdprintf("orig surface %dx%d, %d bytes per pixel\n",
+            src->w, src->h, src->format->BytesPerPixel);
+  tmdprintf("new surface %dx%d, %d bytes per pixel\n",
+            s->w, s->h, s->format->BytesPerPixel);
+
+  /* Now assign function pointers to correct functions based */
+  /* on data format of original and zoomed surfaces:         */
+  getpixel = getpixels[src->format->BytesPerPixel];
   putpixel = putpixels[s->format->BytesPerPixel];
 
-
   SDL_LockSurface(src);
   SDL_LockSurface(s);
 
@@ -571,6 +585,11 @@
   {
     for (y = 0; y < new_h; y++)
     {
+      /* Here we calculate the new RGBA values for each pixel */
+      /* using a "weighted average" of the four pixels in the */
+      /* corresponding location in the orginal surface:       */
+
+      /* figure out which original pixels to use in the calc: */
       floor_x = floor((float) x * xscale);
       ceil_x = floor_x + 1;
       if (ceil_x >= src->w)
@@ -587,6 +606,7 @@
       one_minus_x = 1.0 - fraction_x;
       one_minus_y = 1.0 - fraction_y;
 
+      /* Grab their values:  */
       SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format,
                   &r1, &g1, &b1, &a1);
       SDL_GetRGBA(getpixel(src, ceil_x,  floor_y), src->format,
@@ -596,6 +616,7 @@
       SDL_GetRGBA(getpixel(src, ceil_x,  ceil_y),  src->format,
                   &r4, &g4, &b4, &a4);
 
+      /* Create the weighted averages: */
       n1 = (one_minus_x * r1 + fraction_x * r2);
       n2 = (one_minus_x * r3 + fraction_x * r4);
       r = (one_minus_y * n1 + fraction_y * n2);
@@ -612,21 +633,24 @@
       n2 = (one_minus_x * a3 + fraction_x * a4);
       a = (one_minus_y * n1 + fraction_y * n2);
 
+      /* and put them into our new surface: */
       putpixel(s, x, y, SDL_MapRGBA(s->format, r, g, b, a));
+
     }
   }
 
   SDL_UnlockSurface(s);
   SDL_UnlockSurface(src);
 
+  tmdprintf("\nLeaving zoom():\n");
+
   return s;
-
 }
 
 //FIXME: everything below is slightly modified code from pixels.c and would do
 //       better to be included as such.
 
-//#if 0 //selectively omit from here to the end of file until pixels.c is in
+#if 0 //selectively omit from here to the end of file until pixels.c is in
 
 
 
@@ -674,7 +698,7 @@
 */
 
 #include "pixels.h"
-//#include "compiler.h"
+#include "compiler.h"
 //#include "debug.h"
 
 /* Draw a single pixel into the surface: */
@@ -682,6 +706,8 @@
 {
   Uint8 *p;
 
+//  printf("putpixel8() called\n");
+
   /* Assuming the X/Y values are within the bounds of this surface... */
   if (
       (((unsigned) x < (unsigned) surface->w)
@@ -705,6 +731,8 @@
 {
   Uint8 *p;
 
+//  printf("putpixel16() called\n");
+
   /* Assuming the X/Y values are within the bounds of this surface... */
   if (
       (((unsigned) x < (unsigned) surface->w)
@@ -728,6 +756,8 @@
 {
   Uint8 *p;
 
+//  printf("putpixel24() called\n");
+
   /* Assuming the X/Y values are within the bounds of this surface... */
   if (
       (((unsigned) x < (unsigned) surface->w)
@@ -763,6 +793,8 @@
 {
   Uint8 *p;
 
+//  printf("putpixel32() called\n");
+
   /* Assuming the X/Y values are within the bounds of this surface... */
   if (
       (((unsigned) x < (unsigned) surface->w)
@@ -786,6 +818,8 @@
 {
   Uint8 *p;
 
+//  printf("getpixel8() called\n");
+
   /* get the X/Y values within the bounds of this surface */
   if ((unsigned) x < (unsigned) surface->w)
     x = (x < 0) ? 0 : surface->w - 1;
@@ -812,6 +846,8 @@
 {
   Uint8 *p;
 
+//  printf("getpixel16() called\n");
+
   /* get the X/Y values within the bounds of this surface */
   if ((unsigned) x < (unsigned) surface->w)
     x = (x < 0) ? 0 : surface->w - 1;
@@ -839,6 +875,8 @@
   Uint8 *p;
   Uint32 pixel;
 
+//  printf("getpixel24() called\n");
+
   /* get the X/Y values within the bounds of this surface */
   if ((unsigned) x < (unsigned) surface->w)
     x = (x < 0) ? 0 : surface->w - 1;
@@ -872,6 +910,8 @@
 {
   Uint8 *p;
 
+//  printf("getpixel32() called\n");
+
   /* get the X/Y values within the bounds of this surface */
   if ((unsigned) x < (unsigned) surface->w)
     x = (x < 0) ? 0 : surface->w - 1;
@@ -893,13 +933,24 @@
   return *(Uint32 *) p;		// 32-bit display
 }
 
+/* Function pointer arrays to allow correct function */
+/* to be used according to colorspace:               */
 void (*putpixels[]) (SDL_Surface *, int, int, Uint32) =
 {
-putpixel8, putpixel8, putpixel16, putpixel24, putpixel32};
+  putpixel8,
+  putpixel8,
+  putpixel16,
+  putpixel24,
+  putpixel32
+};
 
-
 Uint32(*getpixels[])(SDL_Surface *, int, int) =
 {
-getpixel8, getpixel8, getpixel16, getpixel24, getpixel32};
+  getpixel8,
+  getpixel8,
+  getpixel16,
+  getpixel24,
+  getpixel32
+};
 
-//#endif
+#endif

Added: tuxmath/trunk/src/compiler.h
===================================================================
--- tuxmath/trunk/src/compiler.h	                        (rev 0)
+++ tuxmath/trunk/src/compiler.h	2008-06-14 19:13:05 UTC (rev 518)
@@ -0,0 +1,157 @@
+/*
+  compiler.h
+
+  Compiler-specific #defines and such
+  for Tux Paint
+
+  Mostly by Albert Cahalan <albert at users.sf.net>
+  Copyright (c) 2002-2006
+
+  http://www.newbreedsoftware.com/tuxpaint/
+
+  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
+  (See COPYING.txt)
+
+  June 14, 2002 - February 18, 2006
+  $Id: compiler.h,v 1.5 2006/08/27 21:00:55 wkendrick Exp $
+
+  June 09, 2008:
+  Brought into TuxMath by Brendan Luchen as part of pixel-manipulation
+  code, with blessings of Bill Kendrick.
+
+*/
+
+#ifdef WIN32
+/* Horrible, dangerous macros. */
+/*
+  The SDL stderr redirection trick doesn't seem to work for perror().
+  This does pretty much the same thing.
+*/
+#define perror(str) ({ \
+  if ( (str) && *(str) ) \
+    fprintf(stderr,"%s : ",(str)); \
+  fprintf(stderr, \
+          "%s [%d]\n", \
+          (errno<_sys_nerr)?_sys_errlist[errno]:"unknown",errno ); \
+})
+
+/*
+  MinGW implementation of isspace() crashes on some Win98 boxes
+  if c is 'out-of-range'.
+*/
+#define isspace(c) (((c) == 0x20) || ((c) >= 0x09 && (c) <= 0x0D))
+
+/*
+  WIN32 and MINGW don't have strcasestr().
+*/
+#define NOMINMAX
+#include "Shlwapi.h"
+#define strcasestr StrStrI
+#endif /* WIN32 */
+
+
+
+
+#ifdef __GNUC__
+// This version has strict type checking for safety.
+// See the "unnecessary" pointer comparison. (from Linux)
+#define min(x,y) ({ \
+  typeof(x) _x = (x);     \
+  typeof(y) _y = (y);     \
+  (void) (&_x == &_y);            \
+  _x < _y ? _x : _y; })
+#define max(x,y) ({ \
+  typeof(x) _x = (x);     \
+  typeof(y) _y = (y);     \
+  (void) (&_x == &_y);            \
+  _x > _y ? _x : _y; })
+#else
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#define clamp(lo,value,hi)    (min(max(value,lo),hi))
+
+
+// since gcc-2.5
+#ifdef __GNUC__
+#define NORETURN __attribute__((__noreturn__))
+#define FUNCTION __attribute__((__const__))	// no access to global mem, even via ptr, and no side effect
+#else
+#define NORETURN
+#define FUNCTION
+#endif
+
+#if !defined(restrict) && __STDC_VERSION__ < 199901
+#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
+#define restrict __restrict__
+#else
+#warning No restrict keyword?
+#define restrict
+#endif
+#endif
+
+
+#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
+// won't alias anything, and aligned enough for anything
+#define MALLOC __attribute__ ((__malloc__))
+// no side effect, may read globals
+#ifndef WIN32
+#define PURE __attribute__ ((__pure__))
+#endif
+// tell gcc what to expect:   if(unlikely(err)) die(err);
+#define likely(x)       __builtin_expect(!!(x),1)
+#define unlikely(x)     __builtin_expect(!!(x),0)
+#define expected(x,y)   __builtin_expect((x),(y))
+#else
+#define MALLOC
+#define PURE
+#define likely(x)       (x)
+#define unlikely(x)     (x)
+#define expected(x,y)   (x)
+#endif
+
+
+#ifdef __powerpc__
+// Ticks at 1/4  the memory bus clock (24.907667 MHz on Albert's Mac Cube)
+// This is good for 80-second diff or 160-second total.
+#define CLOCK_ASM(tbl) asm volatile("mftb %0" : "=r" (tbl))
+#define CLOCK_TYPE unsigned long
+#ifndef CLOCK_SPEED
+// #warning Benchmark times are based on a 99.63 MHz memory bus.
+#define CLOCK_SPEED 24907667.0
+#endif
+#endif
+
+#ifdef __i386__
+#define CLOCK_ASM(tbl) asm volatile("rdtsc" : "=A" (tbl))
+#define CLOCK_TYPE unsigned long long
+#ifndef CLOCK_SPEED
+// #warning Benchmark times are based on a 450 MHz CPU.
+#define CLOCK_SPEED 450000000.0
+#endif
+#endif
+
+#ifndef CLOCK_ASM
+// #warning No idea how to read CPU cycles for you, sorry.
+#define CLOCK_ASM(tbl)
+#define CLOCK_TYPE unsigned long
+#define CLOCK_SPEED 1000000000.0
+#endif
+
+#ifdef NO_ASM
+#undef CLOCK_ASM
+#define CLOCK_ASM(x) x=42
+#endif

Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/game.c	2008-06-14 19:13:05 UTC (rev 518)
@@ -2273,7 +2273,8 @@
 
   if (Opts_UseBkgd())
   {
-    bkgd = IMG_Load(fname);
+    bkgd = LoadBkgd(fname);
+//    bkgd = LoadBkgd("/home/dbruce/red_test.jpg");
     if (bkgd == NULL)
     {
       fprintf(stderr,

Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/loaders.c	2008-06-14 19:13:05 UTC (rev 518)
@@ -63,7 +63,7 @@
   {
 
 #ifdef TUXMATH_DEBUG
-    printf(stderr, "Opened successfully as DIR\n");
+    fprintf(stderr, "Opened successfully as DIR\n");
 #endif
 
     closedir(dp);
@@ -209,7 +209,39 @@
   return final_pic;
 }
 
+/***********************
+	LoadBkgd() : a wrapper for LoadImage() that scales the
+        image to the size of the screen using zoom(), taken
+        from TuxPaint
+************************/
+SDL_Surface* LoadBkgd(char* datafile)
+{
+  SDL_Surface* orig;
+  orig = IMG_Load(datafile);
 
+  if (!orig)
+  {
+    tmdprintf("In LoadBkgd(), LoadImage() returned NULL on %s\n",
+              datafile);
+    return NULL;
+  }
+
+  if ((orig->w == screen->w)
+   && (orig->h == screen->h))
+  {
+    tmdprintf("No zoom required - return bkgd as is\n");
+    return orig;
+  }
+  else
+  { 
+    tmdprintf("Image is %dx%d\n", orig->w, orig->h);
+    tmdprintf("Screen is %dx%d\n", screen->w, screen->h);
+    tmdprintf("Calling zoom() to rescale\n");
+    return zoom(orig, screen->w, screen->h);
+  }
+}
+
+
 sprite* FlipSprite( sprite *in, int X, int Y ) {
 	sprite *out;
 

Modified: tuxmath/trunk/src/pixels.c
===================================================================
--- tuxmath/trunk/src/pixels.c	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/pixels.c	2008-06-14 19:13:05 UTC (rev 518)
@@ -28,7 +28,7 @@
 */
 
 #include "pixels.h"
-//#include "compiler.h"
+#include "compiler.h"
 //#include "debug.h"
 
 /* Draw a single pixel into the surface: */
@@ -37,9 +37,9 @@
   Uint8 *p;
 
   /* Assuming the X/Y values are within the bounds of this surface... */
-  if (
-      (((unsigned) x < (unsigned) surface->w)
-       && ((unsigned) y < (unsigned) surface->h)))
+  if (likely
+      (likely((unsigned) x < (unsigned) surface->w)
+       && likely((unsigned) y < (unsigned) surface->h)))
   {
     // Set a pointer to the exact location in memory of the pixel
     p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
@@ -60,9 +60,9 @@
   Uint8 *p;
 
   /* Assuming the X/Y values are within the bounds of this surface... */
-  if (
-      (((unsigned) x < (unsigned) surface->w)
-       && ((unsigned) y < (unsigned) surface->h)))
+  if (likely
+      (likely((unsigned) x < (unsigned) surface->w)
+       && likely((unsigned) y < (unsigned) surface->h)))
   {
     // Set a pointer to the exact location in memory of the pixel
     p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
@@ -83,9 +83,9 @@
   Uint8 *p;
 
   /* Assuming the X/Y values are within the bounds of this surface... */
-  if (
-      (((unsigned) x < (unsigned) surface->w)
-       && ((unsigned) y < (unsigned) surface->h)))
+  if (likely
+      (likely((unsigned) x < (unsigned) surface->w)
+       && likely((unsigned) y < (unsigned) surface->h)))
   {
     // Set a pointer to the exact location in memory of the pixel
     p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
@@ -118,9 +118,9 @@
   Uint8 *p;
 
   /* Assuming the X/Y values are within the bounds of this surface... */
-  if (
-      (((unsigned) x < (unsigned) surface->w)
-       && ((unsigned) y < (unsigned) surface->h)))
+  if (likely
+      (likely((unsigned) x < (unsigned) surface->w)
+       && likely((unsigned) y < (unsigned) surface->h)))
   {
     // Set a pointer to the exact location in memory of the pixel
     p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
@@ -141,9 +141,9 @@
   Uint8 *p;
 
   /* get the X/Y values within the bounds of this surface */
-  if ((unsigned) x < (unsigned) surface->w)
+  if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
     x = (x < 0) ? 0 : surface->w - 1;
-  if ((unsigned) y < (unsigned) surface->h)
+  if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
     y = (y < 0) ? 0 : surface->h - 1;
 
   /* Set a pointer to the exact location in memory of the pixel
@@ -167,9 +167,9 @@
   Uint8 *p;
 
   /* get the X/Y values within the bounds of this surface */
-  if ((unsigned) x < (unsigned) surface->w)
+  if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
     x = (x < 0) ? 0 : surface->w - 1;
-  if ((unsigned) y < (unsigned) surface->h)
+  if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
     y = (y < 0) ? 0 : surface->h - 1;
 
   /* Set a pointer to the exact location in memory of the pixel
@@ -194,9 +194,9 @@
   Uint32 pixel;
 
   /* get the X/Y values within the bounds of this surface */
-  if ((unsigned) x < (unsigned) surface->w)
+  if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
     x = (x < 0) ? 0 : surface->w - 1;
-  if ((unsigned) y < (unsigned) surface->h)
+  if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
     y = (y < 0) ? 0 : surface->h - 1;
 
   /* Set a pointer to the exact location in memory of the pixel
@@ -227,9 +227,9 @@
   Uint8 *p;
 
   /* get the X/Y values within the bounds of this surface */
-  if ((unsigned) x < (unsigned) surface->w)
+  if (unlikely((unsigned) x > (unsigned) surface->w - 1u))
     x = (x < 0) ? 0 : surface->w - 1;
-  if ((unsigned) y < (unsigned) surface->h)
+  if (unlikely((unsigned) y > (unsigned) surface->h - 1u))
     y = (y < 0) ? 0 : surface->h - 1;
 
   /* Set a pointer to the exact location in memory of the pixel

Deleted: tuxmath/trunk/src/pixels.o
===================================================================
(Binary files differ)

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/titlescreen.h	2008-06-14 19:13:05 UTC (rev 518)
@@ -166,6 +166,7 @@
 TTF_Font* LoadFont(const unsigned char* font_name, int font_size);
 Mix_Chunk   *LoadSound( char* datafile );
 SDL_Surface *LoadImage( char* datafile, int mode );
+SDL_Surface* LoadBkgd(char* datafile);
 sprite      *LoadSprite( char* name, int MODE );
 sprite      *FlipSprite( sprite* in, int X, int Y );
 void         FreeSprite( sprite* gfx );

Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h	2008-06-12 16:58:30 UTC (rev 517)
+++ tuxmath/trunk/src/tuxmath.h	2008-06-14 19:13:05 UTC (rev 518)
@@ -42,7 +42,7 @@
 
 //#define NOSOUND
 /* for conditional compilation of debugging output */
-#define TUXMATH_DEBUG
+//#define TUXMATH_DEBUG
 /* for Tim's feedback speed control code           */
 //#define FEEDBACK_DEBUG
 /* nice inline debugging macro */




More information about the Tux4kids-commits mailing list