changeset 304:3d0b7ca9c8eb trunk

[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
author nenolod
date Thu, 23 Nov 2006 00:02:25 -0800
parents 5e19836a2db2
children 51c40770f6bc
files ChangeLog src/paranormal/drawing.c src/paranormal/drawing.h src/paranormal/wave.c
diffstat 4 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Nov 22 23:00:31 2006 -0800
+++ b/ChangeLog	Thu Nov 23 00:02:25 2006 -0800
@@ -1,3 +1,11 @@
+2006-11-23 07:00:31 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [660]
+  - damn shift key
+  
+  trunk/src/paranormal/containers.c |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2006-11-23 06:59:26 +0000  William Pitcock <nenolod@nenolod.net>
   revision [658]
   - improve beat detection
--- a/src/paranormal/drawing.c	Wed Nov 22 23:00:31 2006 -0800
+++ b/src/paranormal/drawing.c	Thu Nov 23 00:02:25 2006 -0800
@@ -7,6 +7,15 @@
 extern SDL_Surface *screen;
 
 void
+pn_draw_dot (guint x, guint y, guchar value)
+{
+  if (x > pn_image_data->width || x < 0 || y > pn_image_data->height || y < 0)
+    return;
+
+  pn_image_data->surface[0][PN_IMG_INDEX(x, y)] = value;
+}
+
+void
 pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value)
 {
   gint x0 = _x0;
@@ -17,10 +26,7 @@
   gint dx = x1 - x0;
   gint dy = y1 - y0;
 
-  if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0)
-     return;
-
-  pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value;
+  pn_draw_dot(x0, y0, value);
 
   if (dx != 0)
     {
@@ -33,10 +39,7 @@
           x0 += dx;
           y0 = m * x0 + b;
 
-          if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0)
-            continue;
-
-          pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value;
+          pn_draw_dot(x0, y0, value);
         }
     }
 }
--- a/src/paranormal/drawing.h	Wed Nov 22 23:00:31 2006 -0800
+++ b/src/paranormal/drawing.h	Thu Nov 23 00:02:25 2006 -0800
@@ -3,6 +3,7 @@
 #ifndef PN_DRAWING_H
 #define PN_DRAWING_H
 
+void pn_draw_dot (guint x, guint y, guchar value);
 void pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value);
 
 #endif
--- a/src/paranormal/wave.c	Wed Nov 22 23:00:31 2006 -0800
+++ b/src/paranormal/wave.c	Thu Nov 23 00:02:25 2006 -0800
@@ -457,7 +457,7 @@
 {
   struct pn_scope_data *data = (struct pn_scope_data *) op_data;
   gint i;
-  gdouble *xf, *yf, *index, *value;
+  gdouble *xf, *yf, *index, *value, *points;
 
   if (data->reset)
     {
@@ -487,19 +487,23 @@
   yf = dict_variable(data->dict, "y");
   index = dict_variable(data->dict, "index");
   value = dict_variable(data->dict, "value");
+  points = dict_variable(data->dict, "points");
 
   if (data->expr_on_frame != NULL)
     expr_execute(data->expr_on_frame, data->dict);
 
+  if (*points > 513 || *points == 0)
+      *points = 513;
+
   if (data->expr_on_sample != NULL)
     {
-       for (i = 0; i < 513; i++)
+       for (i = 0; i < *points; i++)
           {
              gint x, y;
              static gint oldx, oldy;
 
              *value = 1.0 * pn_sound_data->pcm_data[0][i & 511] / 32768.0;
-             *index = i / 512.0;
+             *index = i / (*points - 1);
 
              expr_execute(data->expr_on_sample, data->dict);