diff --git a/src/compute.c b/src/compute.c index 5005644..d370e17 100644 --- a/src/compute.c +++ b/src/compute.c @@ -12,7 +12,7 @@ * 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. -*/ + */ #include #include @@ -24,306 +24,302 @@ #endif typedef struct t_coord { - gint32 x,y; + gint32 x, y; } t_coord; typedef struct t_complex { - gfloat x,y; + gfloat x, y; } t_complex; static t_screen_parameters scr_par; -static byte* surface1; -static byte* surface2; +static byte *surface1; +static byte *surface2; -static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1 et p2:0-4 */ +static inline t_complex fct(t_complex a, guint32 n, gint32 p1, gint32 p2) /* p1 et p2:0-4 */ { - t_complex b; - gfloat fact; - gfloat an; - gfloat circle_size; - gfloat speed; - gfloat co,si; - - a.x-=scr_par.width/2; - a.y-=scr_par.height/2; - - switch (n) { - case 0: - an=0.025*(p1-2)+0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.25; - speed=(gfloat)2000+p2*500; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - case 1: - an=0.015*(p1-2)+0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.45; - speed=(gfloat)4000+p2*1000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - case 2: - an=0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.25; - speed=(gfloat)400+p2*100; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - case 3: - an=(sin(sqrt(a.x*a.x+a.y*a.y)/20)/20)+0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.25; - speed=(gfloat)4000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - case 4: - an=0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.25; - speed=sin(sqrt(a.x*a.x+a.y*a.y)/5)*3000+4000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - case 5: - b.x=a.x*1.02; - b.y=a.y*1.02; - break; - case 6: - an=0.002; - co=cos(an); - si=sin(an); - circle_size=scr_par.height*0.25; - fact=1+cos(atan(a.x/(a.y+0.00001))*6)*0.02; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - default: - b.x=(gfloat)0.0; - b.y=(gfloat)0.0; - } - b.x += scr_par.width/2; - b.y += scr_par.height/2; - if (b.x < 0.0 ) - b.x = 0.0; - if (b.y < 0.0) - b.y = 0.0; - if (b.x > (gfloat) scr_par.width - 1) - b.x = (gfloat)scr_par.width - 1; - if (b.y > (gfloat) scr_par.height - 1) - b.y = (gfloat)scr_par.height - 1; - return b; + t_complex b; + gfloat fact; + gfloat an; + gfloat circle_size; + gfloat speed; + gfloat co, si; + + a.x -= scr_par.width / 2; + a.y -= scr_par.height / 2; + + switch (n) { + case 0: + an = 0.025 * (p1 - 2) + 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.25; + speed = (gfloat)2000 + p2 * 500; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1; + b.x *= fact; + b.y *= fact; + break; + case 1: + an = 0.015 * (p1 - 2) + 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.45; + speed = (gfloat)4000 + p2 * 1000; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + fact = (sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1; + b.x *= fact; + b.y *= fact; + break; + case 2: + an = 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.25; + speed = (gfloat)400 + p2 * 100; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1; + b.x *= fact; + b.y *= fact; + break; + case 3: + an = (sin(sqrt(a.x * a.x + a.y * a.y) / 20) / 20) + 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.25; + speed = (gfloat)4000; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1; + b.x *= fact; + b.y *= fact; + break; + case 4: + an = 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.25; + speed = sin(sqrt(a.x * a.x + a.y * a.y) / 5) * 3000 + 4000; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1; + b.x *= fact; + b.y *= fact; + break; + case 5: + b.x = a.x * 1.02; + b.y = a.y * 1.02; + break; + case 6: + an = 0.002; + co = cos(an); + si = sin(an); + circle_size = scr_par.height * 0.25; + fact = 1 + cos(atan(a.x / (a.y + 0.00001)) * 6) * 0.02; + b.x = (co * a.x - si * a.y); + b.y = (si * a.x + co * a.y); + b.x *= fact; + b.y *= fact; + break; + default: + b.x = (gfloat)0.0; + b.y = (gfloat)0.0; + } + b.x += scr_par.width / 2; + b.y += scr_par.height / 2; + if (b.x < 0.0) + b.x = 0.0; + if (b.y < 0.0) + b.y = 0.0; + if (b.x > (gfloat)scr_par.width - 1) + b.x = (gfloat)scr_par.width - 1; + if (b.y > (gfloat)scr_par.height - 1) + b.y = (gfloat)scr_par.height - 1; + return b; } /* We are trusting here on vector_field != NULL !!! */ -static inline void compute_generate_sector (guint32 g, guint32 f, guint32 p1, guint32 p2, - guint32 debut, guint32 step, vector_field_t *vector_field) +static inline void compute_generate_sector(guint32 g, guint32 f, guint32 p1, guint32 p2, + guint32 debut, guint32 step, vector_field_t *vector_field) { - const guint32 width = (guint32) vector_field->width; - const guint32 height = (guint32) vector_field->height; - const guint32 prop_transmitted = 249; - const guint32 b_add = g * width * height; - t_interpol *vector = vector_field->vector; - guint32 fin = debut + step; - guint32 cx, cy; + const guint32 width = (guint32)vector_field->width; + const guint32 height = (guint32)vector_field->height; + const guint32 prop_transmitted = 249; + const guint32 b_add = g * width * height; + t_interpol *vector = vector_field->vector; + guint32 fin = debut + step; + guint32 cx, cy; - if (fin > height) - fin = height; - for (cy = debut; cy < fin; cy++) { - for (cx = 0; cx < width; cx++) { - t_complex a; - gfloat fpy; - guint32 rw, lw, add; - guint32 w1, w2, w3, w4; - guint32 x, y; - - a.x = (gfloat) cx; - a.y = (gfloat) cy; - a = fct (a, f, p1, p2); - add = cx + cy * width; - x = (guint32) (a.x); - y = (guint32) (a.y); - vector[b_add+add].coord = (x << 16) | y; + if (fin > height) + fin = height; + for (cy = debut; cy < fin; cy++) { + for (cx = 0; cx < width; cx++) { + t_complex a; + gfloat fpy; + guint32 rw, lw, add; + guint32 w1, w2, w3, w4; + guint32 x, y; - fpy = a.y - floor (a.y); - rw = (guint32) ((a.x - floor (a.x)) * prop_transmitted); - lw = prop_transmitted - rw; - w4 = (guint32) (fpy * rw); - w2 = rw - w4; - w3 = (guint32) (fpy * lw); - w1 = lw - w3; - vector[b_add + add].weight = \ - (w1 << 24) | (w2 << 16) | (w3 << 8) | w4; + a.x = (gfloat)cx; + a.y = (gfloat)cy; + a = fct(a, f, p1, p2); + add = cx + cy * width; + x = (guint32)(a.x); + y = (guint32)(a.y); + vector[b_add + add].coord = (x << 16) | y; + + fpy = a.y - floor(a.y); + rw = (guint32)((a.x - floor(a.x)) * prop_transmitted); + lw = prop_transmitted - rw; + w4 = (guint32)(fpy * rw); + w2 = rw - w4; + w3 = (guint32)(fpy * lw); + w1 = lw - w3; + vector[b_add + add].weight = \ + (w1 << 24) | (w2 << 16) | (w3 << 8) | w4; + } } - } } /* * Public functions */ - -void compute_init (void) +void compute_init(void) { - scr_par.width = config_get_xres(); - scr_par.height = config_get_yres(); - scr_par.scale = config_get_sres(); + scr_par.width = config_get_xres(); + scr_par.height = config_get_yres(); + scr_par.scale = config_get_sres(); - surface1 = (byte*) g_malloc ((gulong)(scr_par.width+1) * (scr_par.height+1)); - surface2 = (byte*) g_malloc ((gulong)(scr_par.width+1) * (scr_par.height+1)); + surface1 = (byte *)g_malloc((gulong)(scr_par.width + 1) * (scr_par.height + 1)); + surface2 = (byte *)g_malloc((gulong)(scr_par.width + 1) * (scr_par.height + 1)); } -void compute_resize (gint32 width, gint32 height) +void compute_resize(gint32 width, gint32 height) { - scr_par.width = width; - scr_par.height = height; - g_free (surface1); - g_free (surface2); - surface1 = (byte*) g_malloc ((gulong)(scr_par.width+1) * (scr_par.height+1)); - surface2 = (byte*) g_malloc ((gulong)(scr_par.width+1) * (scr_par.height+1)); + scr_par.width = width; + scr_par.height = height; + g_free(surface1); + g_free(surface2); + surface1 = (byte *)g_malloc((gulong)(scr_par.width + 1) * (scr_par.height + 1)); + surface2 = (byte *)g_malloc((gulong)(scr_par.width + 1) * (scr_par.height + 1)); } -vector_field_t *compute_vector_field_new (gint32 width, gint32 height) +vector_field_t *compute_vector_field_new(gint32 width, gint32 height) { - vector_field_t *field; + vector_field_t *field; - field = g_new0 (vector_field_t, 1); - field->vector = g_new0 (t_interpol, width * height * NB_FCT); - field->width = width; - field->height = height; - return field; + field = g_new0(vector_field_t, 1); + field->vector = g_new0(t_interpol, width * height * NB_FCT); + field->width = width; + field->height = height; + return field; } -void compute_vector_field_destroy (vector_field_t *vector_field) +void compute_vector_field_destroy(vector_field_t *vector_field) { - g_return_if_fail (vector_field != NULL); + g_return_if_fail(vector_field != NULL); - g_free (vector_field->vector); - g_free (vector_field); - vector_field = NULL; + g_free(vector_field->vector); + g_free(vector_field); + vector_field = NULL; } -void compute_quit () +void compute_quit() { - g_free (surface1); - g_free (surface2); + g_free(surface1); + g_free(surface2); } -void compute_generate_vector_field (vector_field_t *vector_field) +void compute_generate_vector_field(vector_field_t *vector_field) { - guint32 f, i, height; + guint32 f, i, height; - g_return_if_fail (vector_field != NULL); - g_return_if_fail (vector_field->height >= 0); + g_return_if_fail(vector_field != NULL); + g_return_if_fail(vector_field->height >= 0); - height = (guint32) vector_field->height; + height = (guint32)vector_field->height; - for (f = 0; f < NB_FCT; f++) { - for (i = 0; i < height; i += 10) - compute_generate_sector (f, f, 2, 2, i, 10, vector_field); - } + for (f = 0; f < NB_FCT; f++) + for (i = 0; i < height; i += 10) + compute_generate_sector(f, f, 2, 2, i, 10, vector_field); } -inline byte *compute_surface (t_interpol* vector, gint32 width, gint32 height) +inline byte *compute_surface(t_interpol *vector, gint32 width, gint32 height) { - gint32 i,j; - gint32 add_dest=0; - guint32 add_src; - t_interpol *interpol; - register byte* ptr_pix; - guint32 color; - byte* ptr_swap; - - for (j = 0; j < height; j++) - for (i = 0; i < width; i++) { - interpol = &vector[add_dest]; - add_src = (interpol->coord & 0xFFFF) * width + (interpol->coord >> 16); - ptr_pix = &((byte*)surface1)[add_src]; - color = ((guint32)(*(ptr_pix)) * (interpol->weight >> 24) - + (guint32)(*(ptr_pix+1)) * ((interpol->weight & 0xFFFFFF) >> 16) - + (guint32)(*(ptr_pix+width)) * ((interpol->weight & 0xFFFF) >> 8) - + (guint32)(*(ptr_pix+width+1)) * (interpol->weight & 0xFF)) >> 8; - if (color > 255) - surface2[add_dest] = (byte)255; - else - surface2[add_dest] = (byte)color; - add_dest++; - } - ptr_swap = surface2; - surface2 = surface1; - surface1 = ptr_swap; + gint32 i, j; + gint32 add_dest = 0; + guint32 add_src; + t_interpol *interpol; + register byte *ptr_pix; + guint32 color; + byte *ptr_swap; - return surface1; + for (j = 0; j < height; j++) + for (i = 0; i < width; i++) { + interpol = &vector[add_dest]; + add_src = (interpol->coord & 0xFFFF) * width + (interpol->coord >> 16); + ptr_pix = &((byte *)surface1)[add_src]; + color = ((guint32)(*(ptr_pix)) * (interpol->weight >> 24) + + (guint32)(*(ptr_pix + 1)) * ((interpol->weight & 0xFFFFFF) >> 16) + + (guint32)(*(ptr_pix + width)) * ((interpol->weight & 0xFFFF) >> 8) + + (guint32)(*(ptr_pix + width + 1)) * (interpol->weight & 0xFF)) >> 8; + if (color > 255) + surface2[add_dest] = (byte)255; + else + surface2[add_dest] = (byte)color; + add_dest++; + } + ptr_swap = surface2; + surface2 = surface1; + surface1 = ptr_swap; + + return surface1; } #if MMX_DETECTION -inline byte *compute_surface_mmx (t_interpol* vector, gint32 width, gint32 height) +inline byte *compute_surface_mmx(t_interpol *vector, gint32 width, gint32 height) { - /*@unused@*/ - volatile mmx_t mm0, mm1, mm2; - volatile mmx_t offsets, r; - t_interpol *interpol; - gint32 i, j, color; - gint32 add_dest = 0; - guint32 add_src; - register byte* ptr_pix; - byte* ptr_swap; - - for (j = 0; j < height; j++) - for (i = 0; i < width; i++) { - interpol = &vector[add_dest]; - add_src = (interpol->coord & 0xFFFF) * width + (interpol->coord >> 16); - ptr_pix = &((byte*)surface1)[add_src]; - ((guint16*)&offsets)[0] = (guint16)*(ptr_pix+width+1); - ((guint16*)&offsets)[1] = (guint16)*(ptr_pix+width); - ((guint16*)&offsets)[2] = (guint16)*(ptr_pix+1); - ((guint16*)&offsets)[3] = (guint16)*(ptr_pix); - /* MMX mode entry */ - movd_m2r(interpol->weight, mm1); - movq_m2r(offsets, mm2); - pxor_r2r(mm0, mm0); - punpcklbw_r2r(mm0, mm1); - pmaddwd_r2r(mm1, mm2); - movq_r2m(mm2, r); - emms(); - /* MMX mode exit */ - color = (((gint32*)&r)[0] + ((gint32*)&r)[1] ) >> 8; - if (color > 255) - surface2[add_dest] = 255; - else - surface2[add_dest] = (byte)color; - add_dest++; - } - ptr_swap = surface1; - surface1 = surface2; - surface2 = ptr_swap; - return surface1; + /*@unused@*/ + volatile mmx_t mm0, mm1, mm2; + volatile mmx_t offsets, r; + t_interpol *interpol; + gint32 i, j, color; + gint32 add_dest = 0; + guint32 add_src; + register byte *ptr_pix; + byte *ptr_swap; + + for (j = 0; j < height; j++) + for (i = 0; i < width; i++) { + interpol = &vector[add_dest]; + add_src = (interpol->coord & 0xFFFF) * width + (interpol->coord >> 16); + ptr_pix = &((byte *)surface1)[add_src]; + ((guint16 *)&offsets)[0] = (guint16) * (ptr_pix + width + 1); + ((guint16 *)&offsets)[1] = (guint16) * (ptr_pix + width); + ((guint16 *)&offsets)[2] = (guint16) * (ptr_pix + 1); + ((guint16 *)&offsets)[3] = (guint16) * (ptr_pix); + /* MMX mode entry */ + movd_m2r(interpol->weight, mm1); + movq_m2r(offsets, mm2); + pxor_r2r(mm0, mm0); + punpcklbw_r2r(mm0, mm1); + pmaddwd_r2r(mm1, mm2); + movq_r2m(mm2, r); + emms(); + /* MMX mode exit */ + color = (((gint32 *)&r)[0] + ((gint32 *)&r)[1]) >> 8; + if (color > 255) + surface2[add_dest] = 255; + else + surface2[add_dest] = (byte)color; + add_dest++; + } + ptr_swap = surface1; + surface1 = surface2; + surface2 = ptr_swap; + return surface1; } #endif /* MMX_DETECTION */ - - diff --git a/src/compute.h b/src/compute.h index 6d3b0fa..ce6e95d 100644 --- a/src/compute.h +++ b/src/compute.h @@ -19,8 +19,8 @@ * 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. -*/ -#ifndef __INFINITY_COMPUTE__ + */ +#ifndef __INFINITY_COMPUTE__ #define __INFINITY_COMPUTE__ @@ -35,10 +35,8 @@ * Represents the interpollation information. */ typedef struct { - - guint32 coord ; /**< Coordinates of the top left pixel. */ - guint32 weight; /**< 32 bits = 4*8 = weights of the four corners */ - + guint32 coord; /**< Coordinates of the top left pixel. */ + guint32 weight; /**< 32 bits = 4*8 = weights of the four corners */ } t_interpol; @@ -50,11 +48,9 @@ typedef struct { * because this is actually not true. */ typedef struct { - - gint32 width; /**< number of vectors */ - gint32 height; /**< length of each vector */ - t_interpol *vector; /**< pointer to the vector field */ - + gint32 width; /**< number of vectors */ + gint32 height; /**< length of each vector */ + t_interpol * vector; /**< pointer to the vector field */ } vector_field_t; @@ -62,20 +58,20 @@ typedef struct { /* * The constructor of the ::vector_field_t type. */ -vector_field_t *compute_vector_field_new (int width, int height); +vector_field_t *compute_vector_field_new(int width, int height); /** * The destructor of the ::vector_field_t type. * - * @param vector_field Must be non NULL pointer to a + * @param vector_field Must be non NULL pointer to a * ::vector_field_t object. */ -void compute_vector_field_destroy (vector_field_t *vector_field); +void compute_vector_field_destroy(vector_field_t *vector_field); /** * It frees any allocated resource and mades clenaup work. */ -void compute_quit (void); +void compute_quit(void); /** * Initializes this module. @@ -85,19 +81,19 @@ void compute_quit (void); * change, the module must be reinitialized in order to the * changes take effect. */ -void compute_init (void); +void compute_init(void); /** * Tells the module that the screen has been resized. * * \warning May be this will be deprecated. */ -void compute_resize (gint32 width, gint32 height); +void compute_resize(gint32 width, gint32 height); -void compute_generate_vector_field (vector_field_t *vector_field); +void compute_generate_vector_field(vector_field_t *vector_field); -byte *compute_surface (t_interpol* vector, gint32 width, gint32 height); -byte *compute_surface_mmx (t_interpol* vector, gint32 width, gint32 height); +byte *compute_surface(t_interpol *vector, gint32 width, gint32 height); +byte *compute_surface_mmx(t_interpol *vector, gint32 width, gint32 height); #endif /* __INFINITY_COMPUTE__ */ diff --git a/src/config-dialog.c b/src/config-dialog.c index 8f516b8..87c8f3d 100644 --- a/src/config-dialog.c +++ b/src/config-dialog.c @@ -3,260 +3,260 @@ #include "gettext.h" -ConfigDialog* config_dialog_new (void) +ConfigDialog *config_dialog_new(void) { - ConfigDialog *config_win; - GtkTooltips *tooltips; + ConfigDialog *config_win; + GtkTooltips *tooltips; - GtkWidget *window_main; - GtkWidget *vbox_main; - GtkWidget *label_scale_factor; - GtkWidget *hscale_scale_factor; - GtkWidget *frame_general; - GtkWidget *table_general; - GtkWidget *label_effect; - GtkWidget *label_palette; - GtkWidget *label_fps; - GtkWidget *checkbutton_show_title; - GtkWidget *hscale_effect; - GtkWidget *hscale_palette; - GtkObject *spinbutton_fps_adj; - GtkWidget *spinbutton_fps; - GtkWidget *hbuttonbox_main; - GtkWidget *button_ok; - GtkWidget *button_cancel; - GtkWidget *button_apply; + GtkWidget *window_main; + GtkWidget *vbox_main; + GtkWidget *label_scale_factor; + GtkWidget *hscale_scale_factor; + GtkWidget *frame_general; + GtkWidget *table_general; + GtkWidget *label_effect; + GtkWidget *label_palette; + GtkWidget *label_fps; + GtkWidget *checkbutton_show_title; + GtkWidget *hscale_effect; + GtkWidget *hscale_palette; + GtkObject *spinbutton_fps_adj; + GtkWidget *spinbutton_fps; + GtkWidget *hbuttonbox_main; + GtkWidget *button_ok; + GtkWidget *button_cancel; + GtkWidget *button_apply; #if ENABLE_NLS - setlocale (LC_MESSAGES, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - textdomain (GETTEXT_PACKAGE); + setlocale(LC_MESSAGES, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + textdomain(GETTEXT_PACKAGE); #endif - window_main = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (window_main), "window_main", window_main); - gtk_window_set_title (GTK_WINDOW (window_main), _("Infinity Configuration")); - gtk_window_set_type_hint (GTK_WINDOW (window_main), GDK_WINDOW_TYPE_HINT_DIALOG); + window_main = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_object_set_data(GTK_OBJECT(window_main), "window_main", window_main); + gtk_window_set_title(GTK_WINDOW(window_main), _("Infinity Configuration")); + gtk_window_set_type_hint(GTK_WINDOW(window_main), GDK_WINDOW_TYPE_HINT_DIALOG); - vbox_main = gtk_vbox_new (FALSE, 0); - gtk_widget_ref (vbox_main); - gtk_object_set_data_full (GTK_OBJECT (window_main), "vbox_main", vbox_main, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (vbox_main); - gtk_container_add (GTK_CONTAINER (window_main), vbox_main); - gtk_container_set_border_width (GTK_CONTAINER (vbox_main), 2); + vbox_main = gtk_vbox_new(FALSE, 0); + gtk_widget_ref(vbox_main); + gtk_object_set_data_full(GTK_OBJECT(window_main), "vbox_main", vbox_main, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(vbox_main); + gtk_container_add(GTK_CONTAINER(window_main), vbox_main); + gtk_container_set_border_width(GTK_CONTAINER(vbox_main), 2); - frame_general = gtk_frame_new (_("Parameters")); - gtk_widget_ref (frame_general); - gtk_object_set_data_full (GTK_OBJECT (window_main), "frame_general", frame_general, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (frame_general); - gtk_box_pack_start (GTK_BOX (vbox_main), frame_general, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame_general), 2); + frame_general = gtk_frame_new(_("Parameters")); + gtk_widget_ref(frame_general); + gtk_object_set_data_full(GTK_OBJECT(window_main), "frame_general", frame_general, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(frame_general); + gtk_box_pack_start(GTK_BOX(vbox_main), frame_general, TRUE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(frame_general), 2); - table_general = gtk_table_new (5, 3, FALSE); - gtk_widget_ref (table_general); - gtk_object_set_data_full (GTK_OBJECT (window_main), "table_general", table_general, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (table_general); - gtk_container_add (GTK_CONTAINER (frame_general), table_general); - gtk_container_set_border_width (GTK_CONTAINER (table_general), 2); - gtk_table_set_row_spacings (GTK_TABLE (table_general), 2); - gtk_table_set_col_spacings (GTK_TABLE (table_general), 2); + table_general = gtk_table_new(5, 3, FALSE); + gtk_widget_ref(table_general); + gtk_object_set_data_full(GTK_OBJECT(window_main), "table_general", table_general, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(table_general); + gtk_container_add(GTK_CONTAINER(frame_general), table_general); + gtk_container_set_border_width(GTK_CONTAINER(table_general), 2); + gtk_table_set_row_spacings(GTK_TABLE(table_general), 2); + gtk_table_set_col_spacings(GTK_TABLE(table_general), 2); - label_effect = gtk_label_new (_("Effect period:")); - gtk_widget_ref (label_effect); - gtk_object_set_data_full (GTK_OBJECT (window_main), "label_effect", label_effect, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label_effect); - gtk_table_attach (GTK_TABLE (table_general), label_effect, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label_effect), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label_effect), 1, 0); + label_effect = gtk_label_new(_("Effect period:")); + gtk_widget_ref(label_effect); + gtk_object_set_data_full(GTK_OBJECT(window_main), "label_effect", label_effect, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(label_effect); + gtk_table_attach(GTK_TABLE(table_general), label_effect, 0, 1, 0, 1, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label_effect), 0, 0.5); + gtk_misc_set_padding(GTK_MISC(label_effect), 1, 0); - label_palette = gtk_label_new (_("Palette period:")); - gtk_widget_ref (label_palette); - gtk_object_set_data_full (GTK_OBJECT (window_main), "label_palette", label_palette, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label_palette); - gtk_table_attach (GTK_TABLE (table_general), label_palette, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label_palette), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label_palette), 1, 0); + label_palette = gtk_label_new(_("Palette period:")); + gtk_widget_ref(label_palette); + gtk_object_set_data_full(GTK_OBJECT(window_main), "label_palette", label_palette, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(label_palette); + gtk_table_attach(GTK_TABLE(table_general), label_palette, 0, 1, 1, 2, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label_palette), 0, 0.5); + gtk_misc_set_padding(GTK_MISC(label_palette), 1, 0); - label_scale_factor = gtk_label_new (_("Scale Factor")); - gtk_widget_ref (label_scale_factor); - gtk_object_set_data_full (GTK_OBJECT (window_main), "label_scale_factor", label_scale_factor, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label_scale_factor); - gtk_table_attach (GTK_TABLE (table_general), label_scale_factor, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label_scale_factor), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label_scale_factor), 1, 0); + label_scale_factor = gtk_label_new(_("Scale Factor")); + gtk_widget_ref(label_scale_factor); + gtk_object_set_data_full(GTK_OBJECT(window_main), "label_scale_factor", label_scale_factor, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(label_scale_factor); + gtk_table_attach(GTK_TABLE(table_general), label_scale_factor, 0, 1, 2, 3, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label_scale_factor), 0, 0.5); + gtk_misc_set_padding(GTK_MISC(label_scale_factor), 1, 0); - label_fps = gtk_label_new (_("Maximum Frames per Second:")); - gtk_widget_ref (label_fps); - gtk_object_set_data_full (GTK_OBJECT (window_main), "label_fps", label_fps, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (label_fps); - gtk_table_attach (GTK_TABLE (table_general), label_fps, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label_fps), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (label_fps), 1, 0); + label_fps = gtk_label_new(_("Maximum Frames per Second:")); + gtk_widget_ref(label_fps); + gtk_object_set_data_full(GTK_OBJECT(window_main), "label_fps", label_fps, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(label_fps); + gtk_table_attach(GTK_TABLE(table_general), label_fps, 0, 1, 3, 4, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label_fps), 0, 0.5); + gtk_misc_set_padding(GTK_MISC(label_fps), 1, 0); - checkbutton_show_title = gtk_check_button_new_with_label (_("Show current play title")); - gtk_widget_ref (checkbutton_show_title); - gtk_object_set_data_full (GTK_OBJECT (window_main), "checkbutton_show_title", checkbutton_show_title, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (checkbutton_show_title); - gtk_table_attach (GTK_TABLE (table_general), checkbutton_show_title, 0, 1, 4, 5, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); + checkbutton_show_title = gtk_check_button_new_with_label(_("Show current play title")); + gtk_widget_ref(checkbutton_show_title); + gtk_object_set_data_full(GTK_OBJECT(window_main), "checkbutton_show_title", checkbutton_show_title, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(checkbutton_show_title); + gtk_table_attach(GTK_TABLE(table_general), checkbutton_show_title, 0, 1, 4, 5, + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(0), 0, 0); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, checkbutton_show_title, - _("Check it if you want to see the current play " - "title on the Infinity's title bar"), NULL); + tooltips = gtk_tooltips_new(); + gtk_tooltips_set_tip(tooltips, checkbutton_show_title, + _("Check it if you want to see the current play " + "title on the Infinity's title bar"), NULL); - //spinbutton_fps_adj = gtk_adjustment_new (30, 5, 150, 1, 10, 0); - spinbutton_fps_adj = gtk_adjustment_new (config_get_fps(), 5, 150, 1, 10, 0); - spinbutton_fps = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_fps_adj), 1, 0); - gtk_widget_ref (spinbutton_fps); - gtk_object_set_data_full (GTK_OBJECT (window_main), "spinbutton_fps", spinbutton_fps, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (spinbutton_fps); - gtk_table_attach (GTK_TABLE (table_general), spinbutton_fps, 2, 3, 3, 4, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spinbutton_fps), GTK_UPDATE_IF_VALID); + //spinbutton_fps_adj = gtk_adjustment_new (30, 5, 150, 1, 10, 0); + spinbutton_fps_adj = gtk_adjustment_new(config_get_fps(), 5, 150, 1, 10, 0); + spinbutton_fps = gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_fps_adj), 1, 0); + gtk_widget_ref(spinbutton_fps); + gtk_object_set_data_full(GTK_OBJECT(window_main), "spinbutton_fps", spinbutton_fps, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(spinbutton_fps); + gtk_table_attach(GTK_TABLE(table_general), spinbutton_fps, 2, 3, 3, 4, + (GtkAttachOptions)(0), + (GtkAttachOptions)(0), 0, 0); + gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(spinbutton_fps), GTK_UPDATE_IF_VALID); - hscale_effect = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 50, 400, 0, 0, 0))); - gtk_widget_ref (hscale_effect); - gtk_object_set_data_full (GTK_OBJECT (window_main), "hscale_effect", hscale_effect, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hscale_effect); - gtk_table_attach (GTK_TABLE (table_general), hscale_effect, 1, 3, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_scale_set_value_pos (GTK_SCALE (hscale_effect), GTK_POS_LEFT); - gtk_scale_set_digits (GTK_SCALE (hscale_effect), 0); + hscale_effect = gtk_hscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(100, 50, 400, 0, 0, 0))); + gtk_widget_ref(hscale_effect); + gtk_object_set_data_full(GTK_OBJECT(window_main), "hscale_effect", hscale_effect, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(hscale_effect); + gtk_table_attach(GTK_TABLE(table_general), hscale_effect, 1, 3, 0, 1, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_scale_set_value_pos(GTK_SCALE(hscale_effect), GTK_POS_LEFT); + gtk_scale_set_digits(GTK_SCALE(hscale_effect), 0); - gtk_tooltips_set_tip (tooltips, hscale_effect, - _("Time to change between an effect and the " - "next one, in milliseconds."), NULL); + gtk_tooltips_set_tip(tooltips, hscale_effect, + _("Time to change between an effect and the " + "next one, in milliseconds."), NULL); - hscale_palette = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 50, 400, 0, 0, 0))); - gtk_widget_ref (hscale_palette); - gtk_object_set_data_full (GTK_OBJECT (window_main), "hscale_palette", hscale_palette, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hscale_palette); - gtk_table_attach (GTK_TABLE (table_general), hscale_palette, 1, 3, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_scale_set_value_pos (GTK_SCALE (hscale_palette), GTK_POS_LEFT); - gtk_scale_set_digits (GTK_SCALE (hscale_palette), 0); + hscale_palette = gtk_hscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(100, 50, 400, 0, 0, 0))); + gtk_widget_ref(hscale_palette); + gtk_object_set_data_full(GTK_OBJECT(window_main), "hscale_palette", hscale_palette, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(hscale_palette); + gtk_table_attach(GTK_TABLE(table_general), hscale_palette, 1, 3, 1, 2, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_scale_set_value_pos(GTK_SCALE(hscale_palette), GTK_POS_LEFT); + gtk_scale_set_digits(GTK_SCALE(hscale_palette), 0); - gtk_tooltips_set_tip (tooltips, hscale_palette, - _("Time to change between a color and the " - "next one, in milliseconds."), NULL); + gtk_tooltips_set_tip(tooltips, hscale_palette, + _("Time to change between a color and the " + "next one, in milliseconds."), NULL); - hscale_scale_factor = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 1, 2, 0, 0, 0))); - gtk_widget_ref (hscale_scale_factor); - gtk_object_set_data_full (GTK_OBJECT (window_main), "hscale_scale_factor", hscale_scale_factor, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hscale_scale_factor); - gtk_table_attach (GTK_TABLE (table_general), hscale_scale_factor, 1, 3, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_scale_set_value_pos (GTK_SCALE (hscale_scale_factor), GTK_POS_LEFT); - gtk_scale_set_digits (GTK_SCALE (hscale_scale_factor), 0); + hscale_scale_factor = gtk_hscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(1, 1, 2, 0, 0, 0))); + gtk_widget_ref(hscale_scale_factor); + gtk_object_set_data_full(GTK_OBJECT(window_main), "hscale_scale_factor", hscale_scale_factor, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(hscale_scale_factor); + gtk_table_attach(GTK_TABLE(table_general), hscale_scale_factor, 1, 3, 2, 3, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + (GtkAttachOptions)(0), 0, 0); + gtk_scale_set_value_pos(GTK_SCALE(hscale_scale_factor), GTK_POS_LEFT); + gtk_scale_set_digits(GTK_SCALE(hscale_scale_factor), 0); - gtk_tooltips_set_tip (tooltips, hscale_scale_factor, - _("Change only if the system doesn't have " - "enough power to show the screen at " - "a reasonably speed/size relation."), NULL); + gtk_tooltips_set_tip(tooltips, hscale_scale_factor, + _("Change only if the system doesn't have " + "enough power to show the screen at " + "a reasonably speed/size relation."), NULL); - hbuttonbox_main = gtk_hbutton_box_new (); - gtk_widget_ref (hbuttonbox_main); - gtk_object_set_data_full (GTK_OBJECT (window_main), "hbuttonbox_main", hbuttonbox_main, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (hbuttonbox_main); - gtk_box_pack_start (GTK_BOX (vbox_main), hbuttonbox_main, FALSE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox_main), 2); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox_main), GTK_BUTTONBOX_END); + hbuttonbox_main = gtk_hbutton_box_new(); + gtk_widget_ref(hbuttonbox_main); + gtk_object_set_data_full(GTK_OBJECT(window_main), "hbuttonbox_main", hbuttonbox_main, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(hbuttonbox_main); + gtk_box_pack_start(GTK_BOX(vbox_main), hbuttonbox_main, FALSE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbuttonbox_main), 2); + gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox_main), GTK_BUTTONBOX_END); - button_ok = gtk_button_new_with_label (_("Ok")); - gtk_widget_ref (button_ok); - gtk_object_set_data_full (GTK_OBJECT (window_main), "button_ok", button_ok, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button_ok); - gtk_container_add (GTK_CONTAINER (hbuttonbox_main), button_ok); - GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); + button_ok = gtk_button_new_with_label(_("Ok")); + gtk_widget_ref(button_ok); + gtk_object_set_data_full(GTK_OBJECT(window_main), "button_ok", button_ok, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(button_ok); + gtk_container_add(GTK_CONTAINER(hbuttonbox_main), button_ok); + GTK_WIDGET_SET_FLAGS(button_ok, GTK_CAN_DEFAULT); - gtk_tooltips_set_tip (tooltips, button_ok, - _("For to toggle to fullscreen mode, select " - "the Infinity plugin window, and press " - "the Tab key. Pressing Tab again will return " - "to window mode."), NULL); + gtk_tooltips_set_tip(tooltips, button_ok, + _("For to toggle to fullscreen mode, select " + "the Infinity plugin window, and press " + "the Tab key. Pressing Tab again will return " + "to window mode."), NULL); - button_cancel = gtk_button_new_with_label (_("Cancel")); - gtk_widget_ref (button_cancel); - gtk_object_set_data_full (GTK_OBJECT (window_main), "button_cancel", button_cancel, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button_cancel); - gtk_container_add (GTK_CONTAINER (hbuttonbox_main), button_cancel); - GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); + button_cancel = gtk_button_new_with_label(_("Cancel")); + gtk_widget_ref(button_cancel); + gtk_object_set_data_full(GTK_OBJECT(window_main), "button_cancel", button_cancel, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(button_cancel); + gtk_container_add(GTK_CONTAINER(hbuttonbox_main), button_cancel); + GTK_WIDGET_SET_FLAGS(button_cancel, GTK_CAN_DEFAULT); - button_apply = gtk_button_new_with_label (_("Apply")); - gtk_widget_ref (button_apply); - gtk_object_set_data_full (GTK_OBJECT (window_main), "button_apply", button_apply, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show (button_apply); - gtk_container_add (GTK_CONTAINER (hbuttonbox_main), button_apply); - GTK_WIDGET_SET_FLAGS (button_apply, GTK_CAN_DEFAULT); + button_apply = gtk_button_new_with_label(_("Apply")); + gtk_widget_ref(button_apply); + gtk_object_set_data_full(GTK_OBJECT(window_main), "button_apply", button_apply, + (GtkDestroyNotify)gtk_widget_unref); + gtk_widget_show(button_apply); + gtk_container_add(GTK_CONTAINER(hbuttonbox_main), button_apply); + GTK_WIDGET_SET_FLAGS(button_apply, GTK_CAN_DEFAULT); - gtk_widget_grab_default (button_cancel); + gtk_widget_grab_default(button_cancel); - config_win = g_new0 (ConfigDialog, 1); + config_win = g_new0(ConfigDialog, 1); - config_win->window_main = window_main; + config_win->window_main = window_main; - config_win->hscale_effect = hscale_effect; - config_win->hscale_palette = hscale_palette; - config_win->hscale_scale_factor = hscale_scale_factor; - config_win->spinbutton_fps = spinbutton_fps; - config_win->checkbutton_show_title = checkbutton_show_title; + config_win->hscale_effect = hscale_effect; + config_win->hscale_palette = hscale_palette; + config_win->hscale_scale_factor = hscale_scale_factor; + config_win->spinbutton_fps = spinbutton_fps; + config_win->checkbutton_show_title = checkbutton_show_title; - config_win->button_ok = button_ok; - config_win->button_cancel = button_cancel; - config_win->button_apply = button_apply; + config_win->button_ok = button_ok; + config_win->button_cancel = button_cancel; + config_win->button_apply = button_apply; - gtk_tooltips_enable (tooltips); + gtk_tooltips_enable(tooltips); - return config_win; + return config_win; } -void config_dialog_destroy (ConfigDialog *dialog) +void config_dialog_destroy(ConfigDialog *dialog) { - g_return_if_fail (dialog != NULL); + g_return_if_fail(dialog != NULL); - g_free (dialog); + g_free(dialog); } -void config_dialog_show (ConfigDialog *dialog) +void config_dialog_show(ConfigDialog *dialog) { - g_return_if_fail (dialog != NULL); + g_return_if_fail(dialog != NULL); - gtk_window_present (GTK_WINDOW(dialog->window_main)); + gtk_window_present(GTK_WINDOW(dialog->window_main)); } -void config_dialog_hide (ConfigDialog *dialog) +void config_dialog_hide(ConfigDialog *dialog) { - g_return_if_fail (dialog != NULL); + g_return_if_fail(dialog != NULL); - gtk_widget_hide (dialog->window_main); + gtk_widget_hide(dialog->window_main); } diff --git a/src/config-dialog.h b/src/config-dialog.h index 07c2e42..39313b8 100644 --- a/src/config-dialog.h +++ b/src/config-dialog.h @@ -9,28 +9,26 @@ * Here we have all the widgets of config dialog we need to interact to. */ typedef struct { + GtkWidget * window_main; - GtkWidget *window_main; - - /* General stuff */ - GtkWidget *hscale_effect; /**< GtkHScale */ - GtkWidget *hscale_palette; /**< GtkHScale */ - GtkWidget *hscale_scale_factor; /**< GtkHScale */ - GtkWidget *spinbutton_fps; /**< GtkSpinButton */ - GtkWidget *checkbutton_show_title; /** GtkCheckButton */ - - /* Buttons */ - GtkWidget *button_ok; /**< GtkButton */ - GtkWidget *button_cancel; /**< GtkButton */ - GtkWidget *button_apply; /**< GtkButton */ + /* General stuff */ + GtkWidget * hscale_effect; /**< GtkHScale */ + GtkWidget * hscale_palette; /**< GtkHScale */ + GtkWidget * hscale_scale_factor; /**< GtkHScale */ + GtkWidget * spinbutton_fps; /**< GtkSpinButton */ + GtkWidget * checkbutton_show_title; /** GtkCheckButton */ + /* Buttons */ + GtkWidget * button_ok; /**< GtkButton */ + GtkWidget * button_cancel; /**< GtkButton */ + GtkWidget * button_apply; /**< GtkButton */ } ConfigDialog; -ConfigDialog* config_dialog_new (void); -void config_dialog_destroy (ConfigDialog *dialog); +ConfigDialog *config_dialog_new(void); +void config_dialog_destroy(ConfigDialog *dialog); -void config_dialog_show (ConfigDialog *dialog); -void config_dialog_hide (ConfigDialog *dialog); +void config_dialog_show(ConfigDialog *dialog); +void config_dialog_hide(ConfigDialog *dialog); #endif diff --git a/src/cputest.c b/src/cputest.c index fd9b2ad..a1acf95 100644 --- a/src/cputest.c +++ b/src/cputest.c @@ -6,153 +6,152 @@ /* ebx saving is necessary for PIC. gcc seems unable to see it alone */ #if MMX_DETECTION -#define cpuid(index,eax,ebx,ecx,edx)\ - __asm __volatile\ - ("movl %%ebx, %%esi\n\t"\ - "cpuid\n\t"\ - "xchgl %%ebx, %%esi"\ - : "=a" (eax), "=S" (ebx),\ - "=c" (ecx), "=d" (edx)\ - : "0" (index)); +#define cpuid(index, eax, ebx, ecx, edx) \ + __asm __volatile \ + ("movl %%ebx, %%esi\n\t" \ + "cpuid\n\t" \ + "xchgl %%ebx, %%esi" \ + : "=a" (eax), "=S" (ebx), \ + "=c" (ecx), "=d" (edx) \ + : "0" (index)); #endif /* Function to test if multimedia instructions are supported... */ -int mm_support (void) +int mm_support(void) { #if MMX_DETECTION - int rval; - int eax, ebx, ecx, edx; - - __asm__ __volatile__ ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushf\n\t" - "popl %0\n\t" - "movl %0, %1\n\t" - - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xorl $0x200000, %0\n\t" - "push %0\n\t" - "popf\n\t" - - /* ... Get the (hopefully modified) EFLAGS */ - "pushf\n\t" - "popl %0\n\t" - : "=a" (eax), "=c" (ecx) - : - : "cc" - ); - - if (eax == ecx) - return 0; /* CPUID not supported */ - - cpuid(0, eax, ebx, ecx, edx); + int rval; + int eax, ebx, ecx, edx; - if (ebx == 0x756e6547 && - edx == 0x49656e69 && - ecx == 0x6c65746e) { - - /* intel */ - inteltest: - cpuid(1, eax, ebx, ecx, edx); - if ((edx & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (edx & 0x02000000) - rval |= MM_MMXEXT | MM_SSE; - if (edx & 0x04000000) - rval |= MM_SSE2; - return rval; - } else if (ebx == 0x68747541 && - edx == 0x69746e65 && - ecx == 0x444d4163) { - /* AMD */ - cpuid(0x80000000, eax, ebx, ecx, edx); - if ((guint32)eax < 0x80000001) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - if ((edx & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (edx & 0x80000000) - rval |= MM_3DNOW; - if (edx & 0x00400000) - rval |= MM_MMXEXT; - return rval; - } else if (ebx == 0x746e6543 && - edx == 0x48727561 && - ecx == 0x736c7561) { /* "CentaurHauls" */ - /* VIA C3 */ - cpuid(0x80000000, eax, ebx, ecx, edx); - if ((guint32)eax < 0x80000001) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - rval = 0; - if( edx & ( 1 << 31) ) - rval |= MM_3DNOW; - if( edx & ( 1 << 23) ) - rval |= MM_MMX; - if( edx & ( 1 << 24) ) - rval |= MM_MMXEXT; - return rval; - } else if (ebx == 0x69727943 && - edx == 0x736e4978 && - ecx == 0x64616574) { - /* Cyrix Section */ - /* See if extended CPUID level 80000001 is supported */ - /* The value of CPUID/80000001 for the 6x86MX is undefined - according to the Cyrix CPU Detection Guide (Preliminary - Rev. 1.01 table 1), so we'll check the value of eax for - CPUID/0 to see if standard CPUID level 2 is supported. - According to the table, the only CPU which supports level - 2 is also the only one which supports extended CPUID levels. - */ - if (eax != 2) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - if ((eax & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (eax & 0x01000000) - rval |= MM_MMXEXT; - return rval; - } else { - return 0; - } -#else /* not MMX_DETECTION */ - return 0; + __asm__ __volatile__ ( + /* See if CPUID instruction is supported ... */ + /* ... Get copies of EFLAGS into eax and ecx */ + "pushf\n\t" + "popl %0\n\t" + "movl %0, %1\n\t" + + /* ... Toggle the ID bit in one copy and store */ + /* to the EFLAGS reg */ + "xorl $0x200000, %0\n\t" + "push %0\n\t" + "popf\n\t" + + /* ... Get the (hopefully modified) EFLAGS */ + "pushf\n\t" + "popl %0\n\t" + : "=a" (eax), "=c" (ecx) + : + : "cc" + ); + + if (eax == ecx) + return 0; /* CPUID not supported */ + + cpuid(0, eax, ebx, ecx, edx); + + if (ebx == 0x756e6547 && + edx == 0x49656e69 && + ecx == 0x6c65746e) { + /* intel */ +inteltest: + cpuid(1, eax, ebx, ecx, edx); + if ((edx & 0x00800000) == 0) + return 0; + rval = MM_MMX; + if (edx & 0x02000000) + rval |= MM_MMXEXT | MM_SSE; + if (edx & 0x04000000) + rval |= MM_SSE2; + return rval; + } else if (ebx == 0x68747541 && + edx == 0x69746e65 && + ecx == 0x444d4163) { + /* AMD */ + cpuid(0x80000000, eax, ebx, ecx, edx); + if ((guint32)eax < 0x80000001) + goto inteltest; + cpuid(0x80000001, eax, ebx, ecx, edx); + if ((edx & 0x00800000) == 0) + return 0; + rval = MM_MMX; + if (edx & 0x80000000) + rval |= MM_3DNOW; + if (edx & 0x00400000) + rval |= MM_MMXEXT; + return rval; + } else if (ebx == 0x746e6543 && + edx == 0x48727561 && + ecx == 0x736c7561) { /* "CentaurHauls" */ + /* VIA C3 */ + cpuid(0x80000000, eax, ebx, ecx, edx); + if ((guint32)eax < 0x80000001) + goto inteltest; + cpuid(0x80000001, eax, ebx, ecx, edx); + rval = 0; + if (edx & (1 << 31)) + rval |= MM_3DNOW; + if (edx & (1 << 23)) + rval |= MM_MMX; + if (edx & (1 << 24)) + rval |= MM_MMXEXT; + return rval; + } else if (ebx == 0x69727943 && + edx == 0x736e4978 && + ecx == 0x64616574) { + /* Cyrix Section */ + /* See if extended CPUID level 80000001 is supported */ + /* The value of CPUID/80000001 for the 6x86MX is undefined + * according to the Cyrix CPU Detection Guide (Preliminary + * Rev. 1.01 table 1), so we'll check the value of eax for + * CPUID/0 to see if standard CPUID level 2 is supported. + * According to the table, the only CPU which supports level + * 2 is also the only one which supports extended CPUID levels. + */ + if (eax != 2) + goto inteltest; + cpuid(0x80000001, eax, ebx, ecx, edx); + if ((eax & 0x00800000) == 0) + return 0; + rval = MM_MMX; + if (eax & 0x01000000) + rval |= MM_MMXEXT; + return rval; + } else { + return 0; + } +#else /* not MMX_DETECTION */ + return 0; #endif } -int mm_support_check_and_show () +int mm_support_check_and_show() { - int r; - gchar *msg, *tmp; - - r = mm_support (); - if (r & 0) { - g_message ("Infinity: There is not MMX support\n"); - return r; - } - msg = g_strdup ("Infinity: Looking for Multimedia Extensions Support..."); - if (r & MM_MMX) { - tmp = g_strconcat (msg, " MMX", 0); - g_free (msg); - msg = tmp; - } - if (r & MM_3DNOW) { - tmp = g_strconcat (msg, " 3DNOW", 0); - g_free (msg); - msg = tmp; - } - if (r & MM_MMXEXT) { - tmp = g_strconcat (msg, " MMX2", 0); - g_free (msg); - msg = tmp; - } + int r; + gchar *msg, *tmp; + + r = mm_support(); + if (r & 0) { + g_message("Infinity: There is not MMX support\n"); + return r; + } + msg = g_strdup("Infinity: Looking for Multimedia Extensions Support..."); + if (r & MM_MMX) { + tmp = g_strconcat(msg, " MMX", 0); + g_free(msg); + msg = tmp; + } + if (r & MM_3DNOW) { + tmp = g_strconcat(msg, " 3DNOW", 0); + g_free(msg); + msg = tmp; + } + if (r & MM_MMXEXT) { + tmp = g_strconcat(msg, " MMX2", 0); + g_free(msg); + msg = tmp; + } /* * for now this extensions are not used * if (r & MM_SSE) { @@ -165,19 +164,18 @@ int mm_support_check_and_show () * g_free (msg); * msg = tmp; * } -*/ - tmp = g_strconcat (msg, " detected", 0); - g_free (msg); - msg = tmp; - g_message (msg); - g_free (msg); + */ + tmp = g_strconcat(msg, " detected", 0); + g_free(msg); + msg = tmp; + g_message(msg); + g_free(msg); - return r; + return r; } -int mmx_ok (void) +int mmx_ok(void) { - return ( mm_support() & 0x1 ); + return mm_support() & 0x1; } - diff --git a/src/cputest.h b/src/cputest.h index b2ba098..1d58424 100644 --- a/src/cputest.h +++ b/src/cputest.h @@ -1,36 +1,36 @@ /* cputest.h - - Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz - and R. Fisher). Converted to C and improved by Fabrice Bellard -*/ -#ifndef _CPUTEST_H_ -#define _CPUTEST_H_ + * + * Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz + * and R. Fisher). Converted to C and improved by Fabrice Bellard + */ +#ifndef _CPUTEST_H_ +#define _CPUTEST_H_ -#define MM_MMX 0x0001 /* standard MMX */ -#define MM_3DNOW 0x0004 /* AMD 3DNOW */ -#define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ -#define MM_SSE 0x0008 /* SSE functions */ -#define MM_SSE2 0x0010 /* PIV SSE2 functions */ +#define MM_MMX 0x0001 /* standard MMX */ +#define MM_3DNOW 0x0004 /* AMD 3DNOW */ +#define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ +#define MM_SSE 0x0008 /* SSE functions */ +#define MM_SSE2 0x0010 /* PIV SSE2 functions */ /* should be defined by architectures supporting - one or more MultiMedia extension */ -int mm_support (void); + * one or more MultiMedia extension */ +int mm_support(void); /* return the result of mm_support and show the results - to stdout */ -int mm_support_check_and_show (void); + * to stdout */ +int mm_support_check_and_show(void); -/* Function to test if mmx instructions are supported... - Returns 1 if MMX instructions are supported, 0 otherwise */ -int mmx_ok (void); +/* Function to test if mmx instructions are supported... + * Returns 1 if MMX instructions are supported, 0 otherwise */ +int mmx_ok(void); extern unsigned int mm_flags; /*static inline void emms(void) -{ - __asm __volatile ("emms;":::"memory"); -}*/ + * { + * __asm __volatile ("emms;":::"memory"); + * }*/ #endif /* _CPUTEST_H_ */ diff --git a/src/display.c b/src/display.c index 5d71ad9..6b46a32 100644 --- a/src/display.c +++ b/src/display.c @@ -12,7 +12,7 @@ * 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. -*/ + */ #include #include #include @@ -23,8 +23,8 @@ #include "infconfig.h" #include "gettext.h" -#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) -#define assign_max(p,a) ( *p <= a ? *p = a : 0 ) +#define wrap(a) (a < 0 ? 0 : (a > 255 ? 255 : a)) +#define assign_max(p, a) (*p <= a ? *p = a : 0) /* * SDL_HWSURFACE Surface is in video memory @@ -35,8 +35,8 @@ #define VIDEO_FLAGS ((Uint32)(SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_RESIZABLE)) typedef struct sincos { - gint32 i; - gfloat *f; + gint32 i; + gfloat *f; } sincos_t; static gint16 pcm_data[2][512]; @@ -55,129 +55,126 @@ static SDL_Surface *screen = NULL; static SDL_Color color_table[NB_PALETTES][256]; static gint16 current_colors[256]; -static byte* surface1; +static byte *surface1; -static void init_sdl (gint32 width, gint32 height, gint32 scale) +static void init_sdl(gint32 width, gint32 height, gint32 scale) { - if (SDL_Init((Uint32)(SDL_INIT_VIDEO | SDL_INIT_TIMER)) < 0) - g_error (_("Infinity: Couldn't initialize SDL: %s\n"), SDL_GetError()); - screen = SDL_SetVideoMode (width * scale, height * scale, 16, VIDEO_FLAGS); - if (screen == NULL) - g_error (_("Infinity: could not init video mode: %s\n"), SDL_GetError()); - g_message (_("Infinity: SDL SetVideoMode() Ok")); - (void)SDL_ShowCursor (0); - (void)SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + if (SDL_Init((Uint32)(SDL_INIT_VIDEO | SDL_INIT_TIMER)) < 0) + g_error(_("Infinity: Couldn't initialize SDL: %s\n"), SDL_GetError()); + screen = SDL_SetVideoMode(width * scale, height * scale, 16, VIDEO_FLAGS); + if (screen == NULL) + g_error(_("Infinity: could not init video mode: %s\n"), SDL_GetError()); + g_message(_("Infinity: SDL SetVideoMode() Ok")); + (void)SDL_ShowCursor(0); + (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } static void generate_colors() { - gint32 i, k; - gfloat colors[NB_PALETTES][2][3] = {{{1.0,1.0,1.0},{1.0,1.0,1.0}}, - {{2.0,1.5,0.0},{0.0,0.5,2.0}}, - {{0.0,1.0,2.0},{0.0,1.0,0.0}}, - {{0.0,2.0,1.0},{0.0,0.0,1.0}}, - {{2.0,0.0,0.0},{0.0,1.0,1.0}}}; + gint32 i, k; + gfloat colors[NB_PALETTES][2][3] = { { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 1.0 } }, + { { 2.0, 1.5, 0.0 }, { 0.0, 0.5, 2.0 } }, + { { 0.0, 1.0, 2.0 }, { 0.0, 1.0, 0.0 } }, + { { 0.0, 2.0, 1.0 }, { 0.0, 0.0, 1.0 } }, + { { 2.0, 0.0, 0.0 }, { 0.0, 1.0, 1.0 } } }; - for (k = 0; k < NB_PALETTES; k++) { - for (i = 0; i < 128; i++) - { - color_table[k][i].r = (Uint8)(colors[k][0][0]*i); - color_table[k][i].g = (Uint8)(colors[k][0][1]*i); - color_table[k][i].b = (Uint8)(colors[k][0][2]*i); + for (k = 0; k < NB_PALETTES; k++) { + for (i = 0; i < 128; i++) { + color_table[k][i].r = (Uint8)(colors[k][0][0] * i); + color_table[k][i].g = (Uint8)(colors[k][0][1] * i); + color_table[k][i].b = (Uint8)(colors[k][0][2] * i); + color_table[k][i + 128].r = (Uint8)(colors[k][0][0] * 127 + colors[k][1][0] * i); + color_table[k][i + 128].g = (Uint8)(colors[k][0][1] * 127 + colors[k][1][1] * i); + color_table[k][i + 128].b = (Uint8)(colors[k][0][2] * 127 + colors[k][1][2] * i); + } } - for (i = 0; i < 128; i++) - { - color_table[k][i+128].r = (Uint8)(colors[k][0][0]*127+colors[k][1][0]*i); - color_table[k][i+128].g = (Uint8)(colors[k][0][1]*127+colors[k][1][1]*i); - color_table[k][i+128].b = (Uint8)(colors[k][0][2]*127+colors[k][1][2]*i); - } - } } -static void display_surface () +static void display_surface() { - gint32 i, j; - gint16* pdest; - byte* psrc; - gboolean screen_locked; + gint32 i, j; + gint16 *pdest; + byte *psrc; + gboolean screen_locked; - if (SDL_MUSTLOCK(screen)) { - if (SDL_LockSurface (screen) < 0) { - g_error ("Infinity: Cannot lock screen: %s", SDL_GetError ()); - return ; - } - screen_locked = TRUE; - } else - screen_locked = FALSE; - if (scr_par.scale > 1) { - for (i = 0; i < scr_par.height; i++) { - pdest = (gint16*)(screen->pixels + i * screen->pitch * scr_par.scale); - psrc = surface1 + i * scr_par.width; - if (scr_par.scale == 2) { - for (j = 1; j < scr_par.width; j++) { - *(pdest++) = current_colors[*psrc++]; - *(pdest) = *(pdest - 1); - pdest++; - } - memcpy (screen->pixels + i * screen->pitch * 2 + screen->pitch, - screen->pixels + i * screen->pitch * 2, screen->pitch); - } /* else { - for (j=1;jpixels+i*screen->pitch*3+screen->pitch, - screen->pixels+i*screen->pitch*3,screen->pitch); - memcpy(screen->pixels+i*screen->pitch*3+screen->pitch*2, - screen->pixels+i*screen->pitch*3,screen->pitch); - } */ - } /* for */ - } else { - psrc = surface1; - for (i = 0; i < scr_par.height; i++) { - pdest = (gint16*)(screen->pixels + i * screen->pitch); - for (j = 0; j < scr_par.width; j++) - *pdest++ = current_colors[*psrc++]; - } - } - if (screen_locked) - SDL_UnlockSurface (screen); - else - (void)SDL_Flip (screen); + if (SDL_MUSTLOCK(screen)) { + if (SDL_LockSurface(screen) < 0) { + g_error("Infinity: Cannot lock screen: %s", SDL_GetError()); + return; + } + screen_locked = TRUE; + } else { + screen_locked = FALSE; + } + if (scr_par.scale > 1) { + for (i = 0; i < scr_par.height; i++) { + pdest = (gint16 *)(screen->pixels + i * screen->pitch * scr_par.scale); + psrc = surface1 + i * scr_par.width; + if (scr_par.scale == 2) { + for (j = 1; j < scr_par.width; j++) { + *(pdest++) = current_colors[*psrc++]; + *(pdest) = *(pdest - 1); + pdest++; + } + memcpy(screen->pixels + i * screen->pitch * 2 + screen->pitch, + screen->pixels + i * screen->pitch * 2, screen->pitch); + } /* else { + * for (j=1;jpixels+i*screen->pitch*3+screen->pitch, + * screen->pixels+i*screen->pitch*3,screen->pitch); + * memcpy(screen->pixels+i*screen->pitch*3+screen->pitch*2, + * screen->pixels+i*screen->pitch*3,screen->pitch); + * } */ + } /* for */ + } else { + psrc = surface1; + for (i = 0; i < scr_par.height; i++) { + pdest = (gint16 *)(screen->pixels + i * screen->pitch); + for (j = 0; j < scr_par.width; j++) + *pdest++ = current_colors[*psrc++]; + } + } + if (screen_locked) + SDL_UnlockSurface(screen); + else + (void)SDL_Flip(screen); } -#define plot1(x,y,c)\ +#define plot1(x, y, c) \ \ - if ((x)>0 && (x)0 && (y) 0 && (x) < scr_par.width - 3 && (y) > 0 && (y) < scr_par.height - 3) \ + assign_max(&(surface1)[(x) + (y) * scr_par.width], (c)) \ \ -#define plot2(x,y,c)\ -{\ - gint32 ty;\ - if ((x)>0 && (gint32)(x)0 && (gint32)(y) 0 && (gint32)(x) < scr_par.width - 3 && (y) > 0 && (gint32)(y) < scr_par.height - 3) { \ + ty = (gint32)(y) * scr_par.width; \ + assign_max((&(surface1)[(gint32)(x) + ty]), (c)); \ + assign_max((&(surface1)[(gint32)(x) + 1 + ty]), (c)); \ + assign_max((&(surface1)[(gint32)(x) + ty + scr_par.width]), (c)); \ + assign_max((&(surface1)[(gint32)(x) + 1 + ty + scr_par.width]), (c)); \ + } \ + } \ -#define SWAP(x,y)\ - x ^= y;\ - y ^= x;\ +#define SWAP(x, y) \ + x ^= y; \ + y ^= x; \ x ^= y; -static void line (gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c) +static void line(gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c) { - gint32 dx, dy, cxy,dxy; + gint32 dx, dy, cxy, dxy; /* calculate the distances */ - dx = abs (x1 - x2); - dy = abs (y1 - y2); + dx = abs(x1 - x2); + dy = abs(y1 - y2); cxy = 0; if (dy > dx) { /* Follow Y axis */ @@ -185,29 +182,29 @@ static void line (gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c) SWAP(y1, y2); SWAP(x1, x2); } - if (x1 > x2) + if (x1 > x2) dxy = -1; else dxy = 1; - for (y1=y1; y1= dy) { - x1+= dxy; + x1 += dxy; cxy -= dy; } plot1(x1, y1, (byte)c); - } + } } else { /* Follow X axis */ if (x1 > x2) { SWAP(x1, x2); SWAP(y1, y2); } - if (y1 > y2) + if (y1 > y2) dxy = -1; else dxy = 1; - + for (x1 = x1; x1 < x2; x1++) { cxy += dy; if (cxy >= dx) { @@ -215,229 +212,229 @@ static void line (gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c) cxy -= dx; } plot1(x1, y1, (byte)c); - } + } } } /* * Public functions */ - -void display_init (void) +void display_init(void) { scr_par.width = config_get_xres(); scr_par.height = config_get_yres(); scr_par.scale = config_get_sres(); - pcm_data_mutex = SDL_CreateMutex (); - compute_init (); - init_sdl (scr_par.width, scr_par.height, scr_par.scale); - generate_colors (); - effects_load_effects (); - vector_field = compute_vector_field_new (scr_par.width, scr_par.height); - compute_generate_vector_field (vector_field); + pcm_data_mutex = SDL_CreateMutex(); + compute_init(); + init_sdl(scr_par.width, scr_par.height, scr_par.scale); + generate_colors(); + effects_load_effects(); + vector_field = compute_vector_field_new(scr_par.width, scr_par.height); + compute_generate_vector_field(vector_field); } -void display_quit (void) +void display_quit(void) { - compute_vector_field_destroy (vector_field); + compute_vector_field_destroy(vector_field); compute_quit(); - SDL_DestroyMutex (pcm_data_mutex); + SDL_DestroyMutex(pcm_data_mutex); if (screen != NULL) - SDL_FreeSurface (screen); + SDL_FreeSurface(screen); screen = NULL; - SDL_Quit (); + SDL_Quit(); } -void display_resize (gint32 width, gint32 height) +void display_resize(gint32 width, gint32 height) { scr_par.width = width; scr_par.height = height; - screen = SDL_SetVideoMode (scr_par.width * scr_par.scale, - scr_par.height * scr_par.scale, - 16, VIDEO_FLAGS); + screen = SDL_SetVideoMode(scr_par.width * scr_par.scale, + scr_par.height * scr_par.scale, + 16, VIDEO_FLAGS); if (screen == NULL) - g_error (_("Infinity: Couldn't set %dx%d video mode: %s\n"), - scr_par.width * scr_par.scale, scr_par.height * scr_par.scale, - SDL_GetError()); - compute_vector_field_destroy (vector_field); - vector_field = compute_vector_field_new (width, height); - compute_resize (width, height); - compute_generate_vector_field (vector_field); + g_error(_("Infinity: Couldn't set %dx%d video mode: %s\n"), + scr_par.width * scr_par.scale, scr_par.height * scr_par.scale, + SDL_GetError()); + compute_vector_field_destroy(vector_field); + vector_field = compute_vector_field_new(width, height); + compute_resize(width, height); + compute_generate_vector_field(vector_field); } -inline void display_set_pcm_data (const float * data, int channels) +inline void display_set_pcm_data(const float *data, int channels) { if (channels != 2) { - g_critical ("Unsupported number of channels (%d)\n", channels); + g_critical("Unsupported number of channels (%d)\n", channels); return; } /* begin CS */ - g_return_if_fail (SDL_mutexP (pcm_data_mutex) >= 0); + g_return_if_fail(SDL_mutexP(pcm_data_mutex) >= 0); // TODO check this out, different types here... - memcpy (pcm_data, data, 2*512*sizeof(gint16)); - g_return_if_fail (SDL_mutexV (pcm_data_mutex) >= 0); + memcpy(pcm_data, data, 2 * 512 * sizeof(gint16)); + g_return_if_fail(SDL_mutexV(pcm_data_mutex) >= 0); /* end CS */ } -void change_color (gint32 t2, gint32 t1, gint32 w) +void change_color(gint32 t2, gint32 t1, gint32 w) { gint32 i; gint32 r, g, b; for (i = 0; i < 255; i++) { - r = ((color_table[t1][i].r*w+color_table[t2][i].r*(256-w))>>11); - g = ((color_table[t1][i].g*w+color_table[t2][i].g*(256-w))>>10); - b = ((color_table[t1][i].b*w+color_table[t2][i].b*(256-w))>>11); + r = ((color_table[t1][i].r * w + color_table[t2][i].r * (256 - w)) >> 11); + g = ((color_table[t1][i].g * w + color_table[t2][i].g * (256 - w)) >> 10); + b = ((color_table[t1][i].b * w + color_table[t2][i].b * (256 - w)) >> 11); current_colors[i] = (r << 11) + (g << 5) + b; } } -inline void display_blur (guint32 vector_index) +inline void display_blur(guint32 vector_index) { - surface1 = compute_surface (&(vector_field->vector[vector_index]), - vector_field->width, vector_field->height); + surface1 = compute_surface(&(vector_field->vector[vector_index]), + vector_field->width, vector_field->height); display_surface(); } #if MMX_DETECTION -inline void display_blur_mmx (guint32 vector_index) +inline void display_blur_mmx(guint32 vector_index) { - surface1 = compute_surface_mmx (&(vector_field->vector[vector_index]), - vector_field->width, vector_field->height); + surface1 = compute_surface_mmx(&(vector_field->vector[vector_index]), + vector_field->width, vector_field->height); display_surface(); } #endif -void spectral (t_effect* current_effect) +void spectral(t_effect *current_effect) { - gint32 i, halfheight, halfwidth; - gfloat old_y1,old_y2; + gint32 i, halfheight, halfwidth; + gfloat old_y1, old_y2; gfloat y1, y2; const gint32 density_lines = 5; const gint32 step = 4; - const gint32 shift = (current_effect->spectral_shift*scr_par.height)>>8; + const gint32 shift = (current_effect->spectral_shift * scr_par.height) >> 8; /* begin CS */ - g_return_if_fail (SDL_mutexP (pcm_data_mutex) >= 0); - y1 = (gfloat)((((pcm_data[0][0]+pcm_data[1][0])>>9)*current_effect->spectral_amplitude*scr_par.height)>>12); - y2 = (gfloat)((((pcm_data[0][0]+pcm_data[1][0])>>9)*current_effect->spectral_amplitude*scr_par.height)>>12); + g_return_if_fail(SDL_mutexP(pcm_data_mutex) >= 0); + y1 = (gfloat)((((pcm_data[0][0] + pcm_data[1][0]) >> 9) * current_effect->spectral_amplitude * scr_par.height) >> 12); + y2 = (gfloat)((((pcm_data[0][0] + pcm_data[1][0]) >> 9) * current_effect->spectral_amplitude * scr_par.height) >> 12); if (cosw.i != scr_par.width || sinw.i != scr_par.width) { - g_free (cosw.f); - g_free (sinw.f); + g_free(cosw.f); + g_free(sinw.f); sinw.f = cosw.f = NULL; sinw.i = cosw.i = 0; } if (cosw.i == 0 || cosw.f == NULL) { - gfloat halfPI = (gfloat)PI/2; + gfloat halfPI = (gfloat)PI / 2; cosw.i = scr_par.width; if (cosw.f != NULL) - g_free (cosw.f); - cosw.f = g_malloc (sizeof(gfloat) * scr_par.width); - for (i=0; imode_spectre==3) { - if (y1<0.0) - y1=0.0; - if (y2<0.0) - y2=0.0; + if (current_effect->mode_spectre == 3) { + if (y1 < 0.0) + y1 = 0.0; + if (y2 < 0.0) + y2 = 0.0; } halfheight = scr_par.height >> 1; - halfwidth = scr_par.width >> 1; - for (i=step;i>8)* - current_effect->spectral_amplitude*scr_par.height)>>12); - y2=(gfloat)(((pcm_data[0][(i<<9)/scr_par.width/density_lines]>>8)* - current_effect->spectral_amplitude*scr_par.height)>>12); + halfwidth = scr_par.width >> 1; + for (i = step; i < scr_par.width; i += step) { + old_y1 = y1; + old_y2 = y2; + y1 = (gfloat)(((pcm_data[1][(i << 9) / scr_par.width / density_lines] >> 8) * + current_effect->spectral_amplitude * scr_par.height) >> 12); + y2 = (gfloat)(((pcm_data[0][(i << 9) / scr_par.width / density_lines] >> 8) * + current_effect->spectral_amplitude * scr_par.height) >> 12); /* end CS */ - switch (current_effect->mode_spectre) { + switch (current_effect->mode_spectre) { case 0: - line(i-step,halfheight+shift+old_y2, - i,halfheight+shift+y2, + line(i - step, halfheight + shift + old_y2, + i, halfheight + shift + y2, current_effect->spectral_color); break; - case 1: - line(i-step,halfheight+shift+old_y1, - i,halfheight+shift+y1, + case 1: + line(i - step, halfheight + shift + old_y1, + i, halfheight + shift + y1, current_effect->spectral_color); - line(i-step,halfheight-shift+old_y2, - i,halfheight-shift+y2, + line(i - step, halfheight - shift + old_y2, + i, halfheight - shift + y2, current_effect->spectral_color); break; case 2: - line(i-step,halfheight+shift+old_y1, - i,halfheight+shift+y1, + line(i - step, halfheight + shift + old_y1, + i, halfheight + shift + y1, current_effect->spectral_color); - line(i-step,halfheight-shift+old_y1, - i,halfheight-shift+y1, + line(i - step, halfheight - shift + old_y1, + i, halfheight - shift + y1, current_effect->spectral_color); - line(halfwidth+shift+old_y2,i-step, - halfwidth+shift+y2,i, + line(halfwidth + shift + old_y2, i - step, + halfwidth + shift + y2, i, + current_effect->spectral_color); + line(halfwidth - shift + old_y2, i - step, + halfwidth - shift + y2, i, current_effect->spectral_color); - line(halfwidth-shift+old_y2,i-step, - halfwidth-shift+y2,i, - current_effect->spectral_color); break; case 3: - if (y1<0.0) - y1=0.0; - if (y2<0.0) - y2=0.0; + if (y1 < 0.0) + y1 = 0.0; + if (y2 < 0.0) + y2 = 0.0; case 4: - line(halfwidth + cosw.f[i-step] * (shift+old_y1), - halfheight + sinw.f[i-step] * (shift+old_y1), - halfwidth + cosw.f[i] * (shift+y1), - halfheight + sinw.f[i] * (shift+y1), + line(halfwidth + cosw.f[i - step] * (shift + old_y1), + halfheight + sinw.f[i - step] * (shift + old_y1), + halfwidth + cosw.f[i] * (shift + y1), + halfheight + sinw.f[i] * (shift + y1), + current_effect->spectral_color); + line(halfwidth - cosw.f[i - step] * (shift + old_y2), + halfheight + sinw.f[i - step] * (shift + old_y2), + halfwidth - cosw.f[i] * (shift + y2), + halfheight + sinw.f[i] * (shift + y2), current_effect->spectral_color); - line(halfwidth - cosw.f[i-step] * (shift+old_y2), - halfheight + sinw.f[i-step] * (shift+old_y2), - halfwidth - cosw.f[i] * (shift+y2), - halfheight + sinw.f[i] * (shift+y2), - current_effect->spectral_color); break; } } - g_return_if_fail (SDL_mutexV (pcm_data_mutex) >= 0); - if (current_effect->mode_spectre==3 || current_effect->mode_spectre==4) - line(halfwidth + cosw.f[scr_par.width - step] * (shift+y1), - halfheight + sinw.f[scr_par.width - step] * (shift+y1), - halfwidth - cosw.f[scr_par.width - step] * (shift+y2), - halfheight + sinw.f[scr_par.width - step] * (shift+y2), + g_return_if_fail(SDL_mutexV(pcm_data_mutex) >= 0); + if (current_effect->mode_spectre == 3 || current_effect->mode_spectre == 4) { + line(halfwidth + cosw.f[scr_par.width - step] * (shift + y1), + halfheight + sinw.f[scr_par.width - step] * (shift + y1), + halfwidth - cosw.f[scr_par.width - step] * (shift + y2), + halfheight + sinw.f[scr_par.width - step] * (shift + y2), current_effect->spectral_color); + } } /** * \todo current_effect->curve_color must be a byte. This is related to * t_effect typo. */ -void curve (t_effect* current_effect) +void curve(t_effect *current_effect) { gint32 i, j, k; gfloat v, vr; gfloat x, y; - gfloat amplitude = (gfloat) current_effect->curve_amplitude / 256; - + gfloat amplitude = (gfloat)current_effect->curve_amplitude / 256; + for (j = 0; j < 2; j++) { v = 80.0; vr = 0.001; k = current_effect->x_curve; - for (i = 0;i < 64; i++) { - x = cos((gfloat)(k)/(v+v*j*1.34))*scr_par.height*amplitude; - y = sin((gfloat)(k)/(1.756*(v+v*j*0.93)))*scr_par.height*amplitude; - plot2(x*cos((gfloat)k*vr)+y*sin((gfloat)k*vr)+scr_par.width/2, - x*sin((gfloat)k*vr)-y*cos((gfloat)k*vr)+scr_par.height/2, + for (i = 0; i < 64; i++) { + x = cos((gfloat)(k) / (v + v * j * 1.34)) * scr_par.height * amplitude; + y = sin((gfloat)(k) / (1.756 * (v + v * j * 0.93))) * scr_par.height * amplitude; + plot2(x * cos((gfloat)k * vr) + y * sin((gfloat)k * vr) + scr_par.width / 2, + x * sin((gfloat)k * vr) - y * cos((gfloat)k * vr) + scr_par.height / 2, (byte)current_effect->curve_color); k++; } @@ -445,31 +442,31 @@ void curve (t_effect* current_effect) current_effect->x_curve = k; } -void display_toggle_fullscreen (void) +void display_toggle_fullscreen(void) { - if (SDL_WM_ToggleFullScreen (screen) < 0) - g_warning (_("Cannot toggle to fullscreen mode: %s"), SDL_GetError()); + if (SDL_WM_ToggleFullScreen(screen) < 0) + g_warning(_("Cannot toggle to fullscreen mode: %s"), SDL_GetError()); } -void display_save_screen (void) +void display_save_screen(void) { gchar name[256]; - (void) snprintf (name, 255, "screenshot%i%s", rand () % 1000000, ".bmp"); + (void)snprintf(name, 255, "screenshot%i%s", rand() % 1000000, ".bmp"); name[255] = '\0'; - if (SDL_SaveBMP (screen, name) < 0) - g_warning (_("Error while saving file %s: %s"), name, SDL_GetError()); + if (SDL_SaveBMP(screen, name) < 0) + g_warning(_("Error while saving file %s: %s"), name, SDL_GetError()); else - g_message (_("saved")); + g_message(_("saved")); } -inline void display_save_effect (t_effect *effect) +inline void display_save_effect(t_effect *effect) { - effects_save_effect (effect); + effects_save_effect(effect); } -inline void display_load_random_effect (t_effect *effect) +inline void display_load_random_effect(t_effect *effect) { - effects_load_random_effect (effect); + effects_load_random_effect(effect); } diff --git a/src/display.h b/src/display.h index 58ea19b..f1822d6 100644 --- a/src/display.h +++ b/src/display.h @@ -19,8 +19,8 @@ * 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. -*/ -#ifndef __INFINITY_DISPLAY__ + */ +#ifndef __INFINITY_DISPLAY__ #define __INFINITY_DISPLAY__ #include @@ -42,7 +42,7 @@ * library, must be called before any SDL operation and * must not be called when SDL was already started. */ -void display_init (void); +void display_init(void); /** * Closes the display module. @@ -54,10 +54,10 @@ void display_init (void); * inside this function, because display_set_pcm_data() * could be bloqued on a mutex, mutex that display_quit() * will destroy! - * + * * \see display_init(). */ -void display_quit (void); +void display_quit(void); /** * Change the size of the display to the new dimension @@ -67,7 +67,7 @@ void display_quit (void); * screen is resized (i.e. when is resized the window where * the screen is embedded in). */ -void display_resize (gint32 width, gint32 height); +void display_resize(gint32 width, gint32 height); /** * Set \a data as the data PCM data of this module. @@ -78,25 +78,25 @@ void display_resize (gint32 width, gint32 height); * * \see display_quit(). */ -void display_set_pcm_data (const float * data, int channels); +void display_set_pcm_data(const float *data, int channels); -void display_show (void); +void display_show(void); -void change_color (gint32 old_p, gint32 p, gint32 w); -void display_blur (guint32 vector_index); -void display_blur_mmx (guint32 vector_index); -void spectral (t_effect* current_effect); -void curve (t_effect* current_effect); +void change_color(gint32 old_p, gint32 p, gint32 w); +void display_blur(guint32 vector_index); +void display_blur_mmx(guint32 vector_index); +void spectral(t_effect *current_effect); +void curve(t_effect *current_effect); /** * Makes the plugin screen switch to full screen mode. * * \see display_init(). */ -void display_toggle_fullscreen (void); +void display_toggle_fullscreen(void); -void display_save_screen (void); -void display_save_effect (t_effect *effect); -void display_load_random_effect (t_effect *effect); +void display_save_screen(void); +void display_save_effect(t_effect *effect); +void display_load_random_effect(t_effect *effect); #endif /* __INFINITY_DISPLAY__ */ diff --git a/src/effects.c b/src/effects.c index b7b129e..6a7fbeb 100644 --- a/src/effects.c +++ b/src/effects.c @@ -12,25 +12,25 @@ static t_effect effects[100]; static gint32 nb_effects = 0; static gboolean initialized = FALSE; -void effects_save_effect (t_effect *effect) +void effects_save_effect(t_effect *effect) { gchar datafile[256], path[256]; FILE *f; gint32 i; - - g_assert (effect); + + g_assert(effect); f = fopen (EFFECTS_FILE,"a"); if (f == NULL) { g_warning (_("Cannot open file %s for saving effects\n"), EFFECTS_FILE); - return ; + return; } - for (i = 0; i < sizeof(t_effect); i++) - fputc (*((byte*)effect+i), f); - fclose (f); + for (i = 0; i < sizeof(t_effect); i++) + fputc(*((byte *)effect + i), f); + fclose(f); } -void effects_load_effects (void) +void effects_load_effects(void) { gchar path[255]; gchar datafile[255]; @@ -42,13 +42,13 @@ void effects_load_effects (void) if (f == NULL) { g_warning (_("Cannot open file %s for loading effects\n"), EFFECTS_FILE); - return ; + return; } while (!finished) { - byte* ptr_effect = (byte*)&effects[nb_effects]; - for (i=0;i < sizeof(t_effect); i+=4) { - b=fgetc(f); - if (b!=EOF) { + byte *ptr_effect = (byte *)&effects[nb_effects]; + for (i = 0; i < sizeof(t_effect); i += 4) { + b = fgetc(f); + if (b != EOF) { c = fgetc(f); assert(c != EOF); d = fgetc(f); @@ -56,39 +56,39 @@ void effects_load_effects (void) e = fgetc(f); assert(e != EOF); #if BYTE_ORDER == BIG_ENDIAN - ptr_effect[i]=(byte)e; - ptr_effect[i+1]=(byte)d; - ptr_effect[i+2]=(byte)c; - ptr_effect[i+3]=(byte)b; + ptr_effect[i] = (byte)e; + ptr_effect[i + 1] = (byte)d; + ptr_effect[i + 2] = (byte)c; + ptr_effect[i + 3] = (byte)b; #else - ptr_effect[i]=(byte)b; - ptr_effect[i+1]=(byte)c; - ptr_effect[i+2]=(byte)d; - ptr_effect[i+3]=(byte)e; + ptr_effect[i] = (byte)b; + ptr_effect[i + 1] = (byte)c; + ptr_effect[i + 2] = (byte)d; + ptr_effect[i + 3] = (byte)e; #endif - } else - finished=1; + } else { + finished = 1; + } } - nb_effects+=1; + nb_effects++; } - nb_effects -= 1; - fclose (f); + nb_effects--; + fclose(f); } -void effects_load_random_effect (t_effect *effect) +void effects_load_random_effect(t_effect *effect) { gint32 trash; if (!initialized) { - srand (trash); + srand(trash); initialized = TRUE; } if (nb_effects > 0) { gint32 num_effect = rand() % nb_effects; gint32 i; - - for (i = 0; i < sizeof(t_effect); i++) { - *((byte*)effect+i) = *((byte*)(&effects[num_effect])+i); - } + + for (i = 0; i < sizeof(t_effect); i++) + *((byte *)effect + i) = *((byte *)(&effects[num_effect]) + i); } } diff --git a/src/effects.h b/src/effects.h index e492ab5..311459f 100644 --- a/src/effects.h +++ b/src/effects.h @@ -19,8 +19,8 @@ * 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. -*/ -#ifndef __INFINITY_EFFECTS__ + */ +#ifndef __INFINITY_EFFECTS__ #define __INFINITY_EFFECTS__ @@ -33,31 +33,31 @@ * \todo document structure fields. Some of them are two big, byte * would be enough for some of them. */ -typedef struct { - gint32 num_effect; /**< The number of the effect */ - gint32 x_curve; - gint32 curve_color; - gint32 curve_amplitude; - gint32 spectral_amplitude; - gint32 spectral_color; - gint32 mode_spectre; - gint32 spectral_shift; +typedef struct { + gint32 num_effect; /**< The number of the effect */ + gint32 x_curve; + gint32 curve_color; + gint32 curve_amplitude; + gint32 spectral_amplitude; + gint32 spectral_color; + gint32 mode_spectre; + gint32 spectral_shift; } t_effect; /** * Saves the given effect pointed by \a effect to disk. * - * The effect are saved to the file + * The effect are saved to the file * {prefix}/share/xmms/infinity_states, where {prefix} is * usually /usr or /usr/local. * * @param effect Must be a non NULL reference to a ::t_effect * object. */ -void effects_save_effect (t_effect *effect); +void effects_save_effect(t_effect *effect); -void effects_load_effects (void); -void effects_load_random_effect (t_effect *effect); +void effects_load_effects(void); +void effects_load_random_effect(t_effect *effect); #endif /* __INFINITY_EFFECTS__ */ diff --git a/src/gettext.h b/src/gettext.h index a78af2f..cefe3d1 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -1,20 +1,20 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library 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. */ + * Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2, 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 @@ -26,14 +26,14 @@ # include /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which - chokes if dcgettext is defined as a macro. So include it now, to make - later inclusions of a NOP. We don't include - as well because people using "gettext.h" will not include , - and also including would fail on SunOS 4, whereas - is OK. */ + * chokes if dcgettext is defined as a macro. So include it now, to make + * later inclusions of a NOP. We don't include + * as well because people using "gettext.h" will not include , + * and also including would fail on SunOS 4, whereas + * is OK. */ /*#if defined(__sun) || HAVE_LOCALE_H -# include -#endif*/ + # include + #endif*/ #if HAVE_LOCALE_H # include #endif @@ -41,34 +41,34 @@ #else /* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# define gettext(Msgid) ((const char *) (Msgid)) -# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) -# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) + * The casts to 'const char *' serve the purpose of producing warnings + * for invalid uses of the value returned from these functions. + * On pre-ANSI systems without 'const', the config.h file is supposed to + * contain "#define const". */ +# define gettext(Msgid) ((const char *)(Msgid)) +# define dgettext(Domainname, Msgid) ((const char *)(Msgid)) +# define dcgettext(Domainname, Msgid, Category) ((const char *)(Msgid)) # define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) + ((N) == 1 ? (const char *)(Msgid1) : (const char *)(Msgid2)) # define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) + ((N) == 1 ? (const char *)(Msgid1) : (const char *)(Msgid2)) # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) -# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) + ((N) == 1 ? (const char *)(Msgid1) : (const char *)(Msgid2)) +# define textdomain(Domainname) ((const char *)(Domainname)) +# define bindtextdomain(Domainname, Dirname) ((const char *)(Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *)(Codeset)) #endif /* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ + * extraction of messages, but does not call gettext(). The run-time + * translation is done at a different place in the code. + * The argument, String, should be a literal string. Concatenated strings + * and other string expressions won't work. + * The macro's expansion is not parenthesized, so that it is suitable as + * initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String -#define _(String) (gettext(String)) +#define _(String) (gettext(String)) #endif /* _LIBGETTEXT_H */ diff --git a/src/infconfig.c b/src/infconfig.c index 8584df6..5bc354a 100644 --- a/src/infconfig.c +++ b/src/infconfig.c @@ -8,32 +8,32 @@ #include "gettext.h" #include "config-dialog.h" -//#define DEFAULT_WIDTH 500 -#define DEFAULT_WIDTH 512 -//#define DEFAULT_HEIGHT 375 -#define DEFAULT_HEIGHT 288 -#define DEFAULT_TIME_EFFECT 100 -#define DEFAULT_TIME_PALETTE 100 -#define DEFAULT_SCALE_FACTOR 1 -#define DEFAULT_FPS 15 -#define DEFAULT_SHOW_TITLE TRUE +//#define DEFAULT_WIDTH 500 +#define DEFAULT_WIDTH 512 +//#define DEFAULT_HEIGHT 375 +#define DEFAULT_HEIGHT 288 +#define DEFAULT_TIME_EFFECT 100 +#define DEFAULT_TIME_PALETTE 100 +#define DEFAULT_SCALE_FACTOR 1 +#define DEFAULT_FPS 15 +#define DEFAULT_SHOW_TITLE TRUE -#define INFINITY_CONFIG_DIR "/.audacious/infinity" -#define INFINITY_CONFIG_FILE (INFINITY_CONFIG_DIR "/infinity.ini") +#define INFINITY_CONFIG_DIR "/.audacious/infinity" +#define INFINITY_CONFIG_FILE (INFINITY_CONFIG_DIR "/infinity.ini") typedef struct t_config { - gint32 x, y; - gint32 xres; - gint32 yres; - gint32 sres; - gint32 teff; - gint32 tcol; - gint32 fps; - gboolean show_title; + gint32 x, y; + gint32 xres; + gint32 yres; + gint32 sres; + gint32 teff; + gint32 tcol; + gint32 fps; + gboolean show_title; } t_config; -static t_config config = {-1, -1, 0, 0, 0, 0, 0, 0, DEFAULT_SHOW_TITLE}; +static t_config config = { -1, -1, 0, 0, 0, 0, 0, 0, DEFAULT_SHOW_TITLE }; static ConfigDialog *configure_dialog = NULL; /* @@ -53,82 +53,80 @@ static t_config temp_config; /* * Callbacks for config_plugin_config_window */ - static void scale_value_changed(GtkWidget *widget, gpointer data) { - temp_config.sres = ((gint32)(GTK_ADJUSTMENT(widget)->value)); + temp_config.sres = ((gint32)(GTK_ADJUSTMENT(widget)->value)); } static void teff_value_changed(GtkWidget *widget, gpointer data) { - temp_config.teff = ((gint32)(GTK_ADJUSTMENT(widget)->value)); + temp_config.teff = ((gint32)(GTK_ADJUSTMENT(widget)->value)); } static void tcol_value_changed(GtkWidget *widget, gpointer data) { - temp_config.tcol = ((gint32)(GTK_ADJUSTMENT(widget)->value)); + temp_config.tcol = ((gint32)(GTK_ADJUSTMENT(widget)->value)); } -static void on_fps_changed (GtkWidget *widget, gpointer data) +static void on_fps_changed(GtkWidget *widget, gpointer data) { - gint32 value; + gint32 value; - value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(configure_dialog->spinbutton_fps)); - temp_config.fps = value; - g_message ("fps changed to %d", value); + value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(configure_dialog->spinbutton_fps)); + temp_config.fps = value; + g_message("fps changed to %d", value); } -static void on_show_title_toggled (GtkWidget *widget, gpointer data) +static void on_show_title_toggled(GtkWidget *widget, gpointer data) { - temp_config.show_title = !temp_config.show_title; + temp_config.show_title = !temp_config.show_title; } /*static gboolean check_cfg_version (ConfigFile *f) + * { + * gchar *vstr; + * + * if (xmms_cfg_read_string (f, "infinity", "version", &vstr)) + * if (!strcmp (vstr, PACKAGE_VERSION)) + * return TRUE; + * return FALSE; + * + * return TRUE; + * }*/ +static void sync_options() { - gchar *vstr; - - if (xmms_cfg_read_string (f, "infinity", "version", &vstr)) - if (!strcmp (vstr, PACKAGE_VERSION)) - return TRUE; - return FALSE; - - return TRUE; -}*/ - -static void sync_options () -{ - /*g_message ("Synchronizing options: sres %d, teff %d, tcol %d, fps %d", - temp_config.sres, temp_config.teff, temp_config.tcol, temp_config.fps);*/ - config_set_sres (temp_config.sres); - config_set_teff (temp_config.teff); - config_set_tcol (temp_config.tcol); - config_set_fps (temp_config.fps); - config_set_show_title (temp_config.show_title); + /*g_message ("Synchronizing options: sres %d, teff %d, tcol %d, fps %d", + * temp_config.sres, temp_config.teff, temp_config.tcol, temp_config.fps);*/ + config_set_sres(temp_config.sres); + config_set_teff(temp_config.teff); + config_set_tcol(temp_config.tcol); + config_set_fps(temp_config.fps); + config_set_show_title(temp_config.show_title); } -static void apply_clicked (GtkWidget *w, GtkWidget *window) +static void apply_clicked(GtkWidget *w, GtkWidget *window) { - g_message ("Applying changes ..."); - sync_options (); - config_plugin_save_prefs(); + g_message("Applying changes ..."); + sync_options(); + config_plugin_save_prefs(); } -static void ok_clicked (GtkWidget *w, GtkWidget *window) +static void ok_clicked(GtkWidget *w, GtkWidget *window) { - apply_clicked (w, window); - config_dialog_hide (configure_dialog); + apply_clicked(w, window); + config_dialog_hide(configure_dialog); } -static void cancel_clicked (GtkWidget *w, GtkWidget *window) +static void cancel_clicked(GtkWidget *w, GtkWidget *window) { - g_message ("Cancelling changes..."); - config_dialog_hide (configure_dialog); + g_message("Cancelling changes..."); + config_dialog_hide(configure_dialog); } -static void on_config_dialog_destroy (GtkWidget *widget, gpointer data) +static void on_config_dialog_destroy(GtkWidget *widget, gpointer data) { - config_dialog_destroy (configure_dialog); - configure_dialog = NULL; + config_dialog_destroy(configure_dialog); + configure_dialog = NULL; } /* @@ -136,63 +134,63 @@ static void on_config_dialog_destroy (GtkWidget *widget, gpointer data) * saved values. This way after cancel on a configure dialog, if * we reopen it we get the saved values. */ -static void set_config_values (ConfigDialog *config_dialog) +static void set_config_values(ConfigDialog *config_dialog) { - GtkAdjustment *teadj, *tcadj, *scale_adj; + GtkAdjustment *teadj, *tcadj, *scale_adj; - g_return_if_fail (configure_dialog != NULL); + g_return_if_fail(configure_dialog != NULL); - teadj = gtk_range_get_adjustment (GTK_RANGE(config_dialog->hscale_effect)); - gtk_adjustment_set_value (teadj, config_get_teff()); + teadj = gtk_range_get_adjustment(GTK_RANGE(config_dialog->hscale_effect)); + gtk_adjustment_set_value(teadj, config_get_teff()); - tcadj = gtk_range_get_adjustment (GTK_RANGE(config_dialog->hscale_palette)); - gtk_adjustment_set_value (tcadj, config_get_tcol()); + tcadj = gtk_range_get_adjustment(GTK_RANGE(config_dialog->hscale_palette)); + gtk_adjustment_set_value(tcadj, config_get_tcol()); - scale_adj = gtk_range_get_adjustment (GTK_RANGE(config_dialog->hscale_scale_factor)); - gtk_adjustment_set_value (scale_adj, config_get_sres()); + scale_adj = gtk_range_get_adjustment(GTK_RANGE(config_dialog->hscale_scale_factor)); + gtk_adjustment_set_value(scale_adj, config_get_sres()); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(config_dialog->spinbutton_fps), config_get_fps()); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(config_dialog->spinbutton_fps), config_get_fps()); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(config_dialog->checkbutton_show_title), config_get_show_title()); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(config_dialog->checkbutton_show_title), config_get_show_title()); - /* Memorize current values */ - temp_config.sres = config_get_sres(); - temp_config.teff = config_get_teff(); - temp_config.tcol = config_get_tcol(); - temp_config.fps = config_get_fps(); - temp_config.show_title = config_get_show_title(); + /* Memorize current values */ + temp_config.sres = config_get_sres(); + temp_config.teff = config_get_teff(); + temp_config.tcol = config_get_tcol(); + temp_config.fps = config_get_fps(); + temp_config.show_title = config_get_show_title(); } -static void connect_callbacks (ConfigDialog *configure_dialog) +static void connect_callbacks(ConfigDialog *configure_dialog) { - GtkAdjustment *teadj, *tcadj, *scale_adj; + GtkAdjustment *teadj, *tcadj, *scale_adj; - g_return_if_fail (configure_dialog != NULL); + g_return_if_fail(configure_dialog != NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->window_main), "destroy", - GTK_SIGNAL_FUNC(on_config_dialog_destroy), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->window_main), "destroy", + GTK_SIGNAL_FUNC(on_config_dialog_destroy), NULL); - teadj = gtk_range_get_adjustment (GTK_RANGE(configure_dialog->hscale_effect)); - tcadj = gtk_range_get_adjustment (GTK_RANGE(configure_dialog->hscale_palette)); - scale_adj = gtk_range_get_adjustment (GTK_RANGE(configure_dialog->hscale_scale_factor)); + teadj = gtk_range_get_adjustment(GTK_RANGE(configure_dialog->hscale_effect)); + tcadj = gtk_range_get_adjustment(GTK_RANGE(configure_dialog->hscale_palette)); + scale_adj = gtk_range_get_adjustment(GTK_RANGE(configure_dialog->hscale_scale_factor)); - gtk_signal_connect (GTK_OBJECT(teadj), "value-changed", - GTK_SIGNAL_FUNC(teff_value_changed), NULL); - gtk_signal_connect (GTK_OBJECT(tcadj), "value-changed", - GTK_SIGNAL_FUNC(tcol_value_changed), NULL); - gtk_signal_connect (GTK_OBJECT(scale_adj), "value-changed", - GTK_SIGNAL_FUNC(scale_value_changed), NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->spinbutton_fps), "changed", - GTK_SIGNAL_FUNC(on_fps_changed), NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->checkbutton_show_title), "toggled", - GTK_SIGNAL_FUNC(on_show_title_toggled), NULL); + gtk_signal_connect(GTK_OBJECT(teadj), "value-changed", + GTK_SIGNAL_FUNC(teff_value_changed), NULL); + gtk_signal_connect(GTK_OBJECT(tcadj), "value-changed", + GTK_SIGNAL_FUNC(tcol_value_changed), NULL); + gtk_signal_connect(GTK_OBJECT(scale_adj), "value-changed", + GTK_SIGNAL_FUNC(scale_value_changed), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->spinbutton_fps), "changed", + GTK_SIGNAL_FUNC(on_fps_changed), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->checkbutton_show_title), "toggled", + GTK_SIGNAL_FUNC(on_show_title_toggled), NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->button_ok), "clicked", - GTK_SIGNAL_FUNC(ok_clicked), NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->button_cancel), "clicked", - GTK_SIGNAL_FUNC(cancel_clicked), NULL); - gtk_signal_connect (GTK_OBJECT(configure_dialog->button_apply), "clicked", - GTK_SIGNAL_FUNC(apply_clicked), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->button_ok), "clicked", + GTK_SIGNAL_FUNC(ok_clicked), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->button_cancel), "clicked", + GTK_SIGNAL_FUNC(cancel_clicked), NULL); + gtk_signal_connect(GTK_OBJECT(configure_dialog->button_apply), "clicked", + GTK_SIGNAL_FUNC(apply_clicked), NULL); } /* @@ -200,268 +198,256 @@ static void connect_callbacks (ConfigDialog *configure_dialog) * Public functions * */ - - -void config_plugin_load_prefs (void) +void config_plugin_load_prefs(void) { - gint value; - //gboolean bvalue; - GKeyFile * kf; - gchar * config_file_path; - gboolean error, must_update, config_file_usable; + gint value; + //gboolean bvalue; + GKeyFile *kf; + gchar *config_file_path; + gboolean error, must_update, config_file_usable; - kf = g_key_file_new(); - config_file_path = g_strconcat (g_get_home_dir(), INFINITY_CONFIG_FILE, 0); - config_file_usable = g_key_file_load_from_file (kf, config_file_path, G_KEY_FILE_KEEP_COMMENTS, NULL); - error = must_update = FALSE; - if (config_file_usable) { - if (TRUE) { - //TODO if (check_cfg_version (f)) { - // g_message("version Ok"); - if ((value = g_key_file_get_integer (kf, "Preferences", "xres", NULL)) > 0) { - config_set_xres (value); - } else { - error = TRUE; - } - if ((value = g_key_file_get_integer (kf, "Preferences", "yres", NULL)) > 0) { - config_set_yres (value); - } else { - error = TRUE; - } - if ((value = g_key_file_get_integer (kf, "Preferences", "teff", NULL)) > 0) { - config_set_teff (value); - } else { - error = TRUE; - } - if ((value = g_key_file_get_integer (kf, "Preferences", "tcol", NULL)) > 0) { - config_set_tcol (value); - } else { - error = TRUE; - } - if ((value = g_key_file_get_integer (kf, "Preferences", "sres", NULL)) > 0) { - config_set_sres (value); - } else { - error = TRUE; - } - if ((value = g_key_file_get_integer (kf, "Preferences", "fps", NULL)) > 0) { - config_set_fps (value); - } else { - error = TRUE; - } - //config_set_show_title (g_key_file_get_boolean (kf, "Preferences", "show_title", NULL)); + kf = g_key_file_new(); + config_file_path = g_strconcat(g_get_home_dir(), INFINITY_CONFIG_FILE, 0); + config_file_usable = g_key_file_load_from_file(kf, config_file_path, G_KEY_FILE_KEEP_COMMENTS, NULL); + error = must_update = FALSE; + if (config_file_usable) { + if (TRUE) { + //TODO if (check_cfg_version (f)) { + // g_message("version Ok"); + if ((value = g_key_file_get_integer(kf, "Preferences", "xres", NULL)) > 0) + config_set_xres(value); + else + error = TRUE; + if ((value = g_key_file_get_integer(kf, "Preferences", "yres", NULL)) > 0) + config_set_yres(value); + else + error = TRUE; + if ((value = g_key_file_get_integer(kf, "Preferences", "teff", NULL)) > 0) + config_set_teff(value); + else + error = TRUE; + if ((value = g_key_file_get_integer(kf, "Preferences", "tcol", NULL)) > 0) + config_set_tcol(value); + else + error = TRUE; + if ((value = g_key_file_get_integer(kf, "Preferences", "sres", NULL)) > 0) + config_set_sres(value); + else + error = TRUE; + if ((value = g_key_file_get_integer(kf, "Preferences", "fps", NULL)) > 0) + config_set_fps(value); + else + error = TRUE; + //config_set_show_title (g_key_file_get_boolean (kf, "Preferences", "show_title", NULL)); - /* FIXME for now these are not used */ - //xmms_cfg_read_int (f, "infinity", "xorig", &value); - //config_set_x (value); - //xmms_cfg_read_int (f, "infinity", "yorig", &value); - //config_set_y (value); - } else { - config_set_default_values (); - must_update = TRUE; - } - } else { - config_set_default_values (); - must_update = TRUE; - } - g_free (config_file_path); - g_key_file_free (kf); + /* FIXME for now these are not used */ + //xmms_cfg_read_int (f, "infinity", "xorig", &value); + //config_set_x (value); + //xmms_cfg_read_int (f, "infinity", "yorig", &value); + //config_set_y (value); + } else { + config_set_default_values(); + must_update = TRUE; + } + } else { + config_set_default_values(); + must_update = TRUE; + } + g_free(config_file_path); + g_key_file_free(kf); - if (error || must_update) { - if (error) - g_message ("Fixing errors on Infinity's configure file..."); - else - g_message ("Updating Infinity's configure file..."); + if (error || must_update) { + if (error) + g_message("Fixing errors on Infinity's configure file..."); + else + g_message("Updating Infinity's configure file..."); - config_plugin_save_prefs(); - } + config_plugin_save_prefs(); + } } -void config_plugin_save_prefs (void) +void config_plugin_save_prefs(void) { - gchar * config_file_path, * config_dir_path; - GKeyFile * kf; - gboolean ok; - gchar * preferences; - gsize length; - - kf = g_key_file_new(); - config_dir_path = g_strconcat (g_get_home_dir(), INFINITY_CONFIG_DIR, 0); - config_file_path = g_strconcat (g_get_home_dir(), INFINITY_CONFIG_FILE, 0); - ok = g_key_file_load_from_file (kf, config_file_path, G_KEY_FILE_KEEP_COMMENTS, NULL); - if (!ok) { - g_message (_("Infinity plugin .ini file not found")); - if (!g_file_test (config_dir_path, G_FILE_TEST_EXISTS)) { - g_message (_("Creating Infinity plugin config directory '%s'"), INFINITY_CONFIG_DIR); - if (g_mkdir_with_parents (config_dir_path, S_IRWXU) != 0) { + gchar *config_file_path, *config_dir_path; + GKeyFile *kf; + gboolean ok; + gchar *preferences; + gsize length; - g_warning (_("Cannot save preferences: unable to create directory '%s'"), config_dir_path); - g_free (config_file_path); - g_free (config_dir_path); - g_key_file_free (kf); - return; - } - } - } - if (!config_is_initialized ()) { - config_set_default_values (); - } - //g_key_file_set_value (kf, "Preferences", "version", PACKAGE_VERSION); - g_key_file_set_integer (kf, "Preferences", "xres", config_get_xres()); - g_key_file_set_integer (kf, "Preferences", "yres", config_get_yres()); - g_key_file_set_integer (kf, "Preferences", "teff", config_get_teff()); - g_key_file_set_integer (kf, "Preferences", "tcol", config_get_tcol()); - g_key_file_set_integer (kf, "Preferences", "sres", config_get_sres()); - g_key_file_set_integer (kf, "Preferences", "fps", config_get_fps()); - //g_key_file_set_boolean (kf, "Preferences", "show_title", config_get_show_title()); - preferences = g_key_file_to_data (kf, &length, NULL); - ok = g_file_set_contents (config_file_path, preferences, length, NULL); - if (!ok) { - g_warning (_("Error saving preferences")); - } - g_free (preferences); - g_free (config_file_path); - g_free (config_dir_path); - g_key_file_free (kf); + kf = g_key_file_new(); + config_dir_path = g_strconcat(g_get_home_dir(), INFINITY_CONFIG_DIR, 0); + config_file_path = g_strconcat(g_get_home_dir(), INFINITY_CONFIG_FILE, 0); + ok = g_key_file_load_from_file(kf, config_file_path, G_KEY_FILE_KEEP_COMMENTS, NULL); + if (!ok) { + g_message(_("Infinity plugin .ini file not found")); + if (!g_file_test(config_dir_path, G_FILE_TEST_EXISTS)) { + g_message(_("Creating Infinity plugin config directory '%s'"), INFINITY_CONFIG_DIR); + if (g_mkdir_with_parents(config_dir_path, S_IRWXU) != 0) { + g_warning(_("Cannot save preferences: unable to create directory '%s'"), config_dir_path); + g_free(config_file_path); + g_free(config_dir_path); + g_key_file_free(kf); + return; + } + } + } + if (!config_is_initialized()) + config_set_default_values(); + //g_key_file_set_value (kf, "Preferences", "version", PACKAGE_VERSION); + g_key_file_set_integer(kf, "Preferences", "xres", config_get_xres()); + g_key_file_set_integer(kf, "Preferences", "yres", config_get_yres()); + g_key_file_set_integer(kf, "Preferences", "teff", config_get_teff()); + g_key_file_set_integer(kf, "Preferences", "tcol", config_get_tcol()); + g_key_file_set_integer(kf, "Preferences", "sres", config_get_sres()); + g_key_file_set_integer(kf, "Preferences", "fps", config_get_fps()); + //g_key_file_set_boolean (kf, "Preferences", "show_title", config_get_show_title()); + preferences = g_key_file_to_data(kf, &length, NULL); + ok = g_file_set_contents(config_file_path, preferences, length, NULL); + if (!ok) + g_warning(_("Error saving preferences")); + g_free(preferences); + g_free(config_file_path); + g_free(config_dir_path); + g_key_file_free(kf); } -void config_set_default_values (void) +void config_set_default_values(void) { - config_set_x (20); - config_set_y (10); - config_set_xres (DEFAULT_WIDTH); - config_set_yres (DEFAULT_HEIGHT); - config_set_teff (DEFAULT_TIME_EFFECT); - config_set_tcol (DEFAULT_TIME_PALETTE); - config_set_sres (DEFAULT_SCALE_FACTOR); - config_set_fps (DEFAULT_FPS); - config_set_show_title (DEFAULT_SHOW_TITLE); + config_set_x(20); + config_set_y(10); + config_set_xres(DEFAULT_WIDTH); + config_set_yres(DEFAULT_HEIGHT); + config_set_teff(DEFAULT_TIME_EFFECT); + config_set_tcol(DEFAULT_TIME_PALETTE); + config_set_sres(DEFAULT_SCALE_FACTOR); + config_set_fps(DEFAULT_FPS); + config_set_show_title(DEFAULT_SHOW_TITLE); } -gboolean config_is_initialized (void) +gboolean config_is_initialized(void) { - /* FIXME mhm, ugly thing... */ - //return ((config.x > -1) && (config.y > -1) && - return ((config.xres != 0) && (config.yres != 0) && - (config.sres != 0) && (config.teff != 0) && - (config.tcol != 0) && (config.fps != 0)); + /* FIXME mhm, ugly thing... */ + //return ((config.x > -1) && (config.y > -1) && + return (config.xres != 0) && (config.yres != 0) && + (config.sres != 0) && (config.teff != 0) && + (config.tcol != 0) && (config.fps != 0); } -void config_plugin_config_window (void) +void config_plugin_config_window(void) { #if ENABLE_NLS - setlocale (LC_MESSAGES, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - textdomain (GETTEXT_PACKAGE); + setlocale(LC_MESSAGES, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + textdomain(GETTEXT_PACKAGE); #endif - if (configure_dialog) { - set_config_values (configure_dialog); - config_dialog_show (configure_dialog); - return; - } + if (configure_dialog) { + set_config_values(configure_dialog); + config_dialog_show(configure_dialog); + return; + } - config_plugin_load_prefs (); - if (!config_is_initialized ()) { - config_set_default_values (); - } + config_plugin_load_prefs(); + if (!config_is_initialized()) + config_set_default_values(); - configure_dialog = config_dialog_new (); + configure_dialog = config_dialog_new(); - set_config_values (configure_dialog); + set_config_values(configure_dialog); - connect_callbacks (configure_dialog); + connect_callbacks(configure_dialog); - config_dialog_show (configure_dialog); + config_dialog_show(configure_dialog); } -void config_set_x (gint32 value) +void config_set_x(gint32 value) { - config.x = value; + config.x = value; } -void config_set_y (gint32 value) +void config_set_y(gint32 value) { - config.y = value; + config.y = value; } -void config_set_xres (gint32 value) +void config_set_xres(gint32 value) { - config.xres = value; + config.xres = value; } -void config_set_yres (gint32 value) +void config_set_yres(gint32 value) { - config.yres = value; + config.yres = value; } -void config_set_teff (gint32 value) +void config_set_teff(gint32 value) { - config.teff = value; + config.teff = value; } -void config_set_tcol (gint32 value) +void config_set_tcol(gint32 value) { - config.tcol = value; + config.tcol = value; } -void config_set_sres (gint32 value) +void config_set_sres(gint32 value) { - config.sres = value; + config.sres = value; } -void config_set_fps (gint32 value) +void config_set_fps(gint32 value) { - config.fps = value; + config.fps = value; } -void config_set_show_title (gboolean value) +void config_set_show_title(gboolean value) { - config.show_title = value; + config.show_title = value; } -gint32 config_get_x (void) +gint32 config_get_x(void) { - return config.x; + return config.x; } -gint32 config_get_y (void) +gint32 config_get_y(void) { - return config.y; + return config.y; } -gint32 config_get_xres (void) +gint32 config_get_xres(void) { - return config.xres; + return config.xres; } -gint32 config_get_yres (void) +gint32 config_get_yres(void) { - return config.yres; + return config.yres; } -gint32 config_get_teff (void) +gint32 config_get_teff(void) { - return config.teff; + return config.teff; } -gint32 config_get_tcol (void) +gint32 config_get_tcol(void) { - return config.tcol; + return config.tcol; } -gint32 config_get_sres (void) +gint32 config_get_sres(void) { - return config.sres; + return config.sres; } -gint32 config_get_fps (void) +gint32 config_get_fps(void) { - return config.fps; + return config.fps; } -gboolean config_get_show_title (void) +gboolean config_get_show_title(void) { - return config.show_title; + return config.show_title; } diff --git a/src/infconfig.h b/src/infconfig.h index a18453b..2eb956f 100644 --- a/src/infconfig.h +++ b/src/infconfig.h @@ -12,8 +12,8 @@ * 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. -*/ -#ifndef __INFINITY_CONFIG__ + */ +#ifndef __INFINITY_CONFIG__ #define __INFINITY_CONFIG__ @@ -30,54 +30,54 @@ * of the config module. */ typedef struct _t_screen_parameters { - gint32 x, y; - gint32 width; - gint32 height; - gint32 scale; - gint32 bpp; /**< bytes per pixels. */ + gint32 x, y; + gint32 width; + gint32 height; + gint32 scale; + gint32 bpp; /**< bytes per pixels. */ } t_screen_parameters; /* * Read user preferences from ~/.xmms/config file */ -void config_plugin_load_prefs (void); +void config_plugin_load_prefs(void); -void config_plugin_save_prefs (void); +void config_plugin_save_prefs(void); -void config_set_default_values (void); +void config_set_default_values(void); /* * \return TRUE if config_plugin_load_prefs() or * config_set_default_values() has been called. */ -gboolean config_is_initialized (void); +gboolean config_is_initialized(void); /* - * Open a window to let the user choose and + * Open a window to let the user choose and * save your options. */ -void config_plugin_config_window (void); +void config_plugin_config_window(void); -void config_set_x (gint32 value); -void config_set_y (gint32 value); -void config_set_xres (gint32 value); -void config_set_yres (gint32 value); -void config_set_teff (gint32 value); -void config_set_tcol (gint32 value); -void config_set_sres (gint32 value); -void config_set_fps (gint32 value); -void config_set_show_title (gboolean value); +void config_set_x(gint32 value); +void config_set_y(gint32 value); +void config_set_xres(gint32 value); +void config_set_yres(gint32 value); +void config_set_teff(gint32 value); +void config_set_tcol(gint32 value); +void config_set_sres(gint32 value); +void config_set_fps(gint32 value); +void config_set_show_title(gboolean value); -gint32 config_get_x (void); -gint32 config_get_y (void); -gint32 config_get_xres (void); -gint32 config_get_yres (void); -gint32 config_get_teff (void); -gint32 config_get_tcol (void); -gint32 config_get_sres (void); -gint32 config_get_fps (void); -gboolean config_get_show_title (void); +gint32 config_get_x(void); +gint32 config_get_y(void); +gint32 config_get_xres(void); +gint32 config_get_yres(void); +gint32 config_get_teff(void); +gint32 config_get_tcol(void); +gint32 config_get_sres(void); +gint32 config_get_fps(void); +gboolean config_get_show_title(void); #endif /* __INFINITY_CONFIG__ */ diff --git a/src/main.c b/src/main.c index 7909d55..1560151 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ * 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. -*/ + */ #include #include #include @@ -34,72 +34,72 @@ static const char infinity_about[] = "Version " PACKAGE_VERSION "\n\n" "https://github.com/dprotti/infinity-plugin"); -static bool_t plugin_init (void); -static void plugin_close (void); -static void clear (void); +static bool_t plugin_init(void); +static void plugin_close(void); +static void clear(void); /* * Registers plugin with Audacious. */ -AUD_VIS_PLUGIN ( - .name = "Infinity", - .init = plugin_init, - .cleanup = plugin_close, - .take_message = NULL, +AUD_VIS_PLUGIN( + .name = "Infinity", + .init = plugin_init, + .cleanup = plugin_close, + .take_message = NULL, .about = NULL, .about_text = infinity_about, - .configure = config_plugin_config_window, - //.playback_stop = NULL, + .configure = config_plugin_config_window, + //.playback_stop = NULL, - /* reset internal state and clear display */ - .clear = clear, + /* reset internal state and clear display */ + .clear = clear, - /* 512 frames of a single-channel PCM signal */ - .render_mono_pcm = NULL, + /* 512 frames of a single-channel PCM signal */ + .render_mono_pcm = NULL, - /* 512 frames of an interleaved multi-channel PCM signal */ - .render_multi_pcm = renderer_render_multi_pcm, + /* 512 frames of an interleaved multi-channel PCM signal */ + .render_multi_pcm = renderer_render_multi_pcm, - /* intensity of frequencies 1/512, 2/512, ..., 256/512 of sample rate */ - .render_freq = NULL, + /* intensity of frequencies 1/512, 2/512, ..., 256/512 of sample rate */ + .render_freq = NULL, - /* GtkWidget * (* get_widget) (void); */ - .get_widget = NULL -); + /* GtkWidget * (* get_widget) (void); */ + .get_widget = NULL + ); -static void clear (void) { - g_message ("TODO implement clear()"); +static void clear(void) +{ + g_message("TODO implement clear()"); } -static bool_t plugin_init (void) +static bool_t plugin_init(void) { #if ENABLE_NLS - (void) setlocale (LC_MESSAGES, ""); - (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - (void) textdomain (GETTEXT_PACKAGE); + (void)setlocale(LC_MESSAGES, ""); + (void)bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + (void)textdomain(GETTEXT_PACKAGE); #endif - g_message (_("Infinity commands:\n" - "- Space:\tchange effect.\n" - "- Tab:\t\ttoggle full-screen.\n" - "- Up/Down:\tup/down main volume.\n" - "- Left/Right:\treward/forward actual played song, if any.\n" - "- z:\t\tprevious song.\n" - "- x:\t\tplay.\n" - "- c:\t\tpause.\n" - "- v:\t\tstop.\n" - "- b:\t\tnext song.\n" - "- Enter:\tswitch to interactive mode.\n\t\t(works only if infinity was configured with --enable-debug option)\n" - "- F11:\t\tscreenshot.\n" - "- F12:\t\tchange palette.")); - config_plugin_load_prefs (); - renderer_init (); - return TRUE; + g_message(_("Infinity commands:\n" + "- Space:\tchange effect.\n" + "- Tab:\t\ttoggle full-screen.\n" + "- Up/Down:\tup/down main volume.\n" + "- Left/Right:\treward/forward actual played song, if any.\n" + "- z:\t\tprevious song.\n" + "- x:\t\tplay.\n" + "- c:\t\tpause.\n" + "- v:\t\tstop.\n" + "- b:\t\tnext song.\n" + "- Enter:\tswitch to interactive mode.\n\t\t(works only if infinity was configured with --enable-debug option)\n" + "- F11:\t\tscreenshot.\n" + "- F12:\t\tchange palette.")); + config_plugin_load_prefs(); + renderer_init(); + return TRUE; } -static void plugin_close (void) +static void plugin_close(void) { - config_plugin_save_prefs (); - renderer_finish (); + config_plugin_save_prefs(); + renderer_finish(); } - diff --git a/src/main.c.orig b/src/main.c.orig deleted file mode 100644 index 0ce1e5c..0000000 --- a/src/main.c.orig +++ /dev/null @@ -1,168 +0,0 @@ -/** - * \file main.c - * - * \brief The main module of Infinity plugin. - * - * The only thing that a XMMS visualization plugin has to do - * (from the point of view of XMMS) is to export a function called - * get_vplugin_info() wich returns a pointer to a VisPlugin structure. - * This struct is defined in xmms/plugin.h. It contains pointers to - * functions which will be called on the ocurrence of certain events. - */ - -/* - * 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 Library 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. -*/ -#include -#include -#include -#include -#include - -#include "config.h" -#include "infconfig.h" -#include "renderer.h" -#include "gettext.h" - - -VisPlugin *get_vplugin_info(void); - - -static void plugin_init (void); -static void plugin_close (void); -static void plugin_about (void); - -/** - * Structure shared with XMMS in order to register and get information - * about the plugin. - * - * The \a VisPlugin type is defined on . XMMS will - * obtain a reference to this structure calling ::get_vplugin_info() - * when started. - */ -static VisPlugin sdlblur_vp = { - NULL, /**< Handle, filled in by xmms */ - NULL, /**< Filename, filled in by xmms */ - 0, /**< XMMS Session ID, filled in by XMMS */ - "Infinity " PACKAGE_VERSION, /**< description */ - 2, /**< Number of PCM channels wanted */ - 0, /**< Number of freq channels wanted */ - plugin_init, /**< Called when plugin is enabled */ - plugin_close, /**< Called when plugin is disabled */ - plugin_about, /**< Show the about box */ - config_plugin_config_window, /**< Show the configure box */ - NULL, /**< - void (*disable_plugin)(struct _VisPlugin *) - - Called to disable plugin, filled in by XMMS. - Must be called with a pointer to our plugin - struct to disable the plugin */ - NULL, /**< Called when playback starts */ - NULL, /**< Called when playback stops */ - renderer_set_pcm_data, /**< Render the PCM data */ - NULL, /**< Render the freq data */ -}; - - -static void plugin_init(void) -{ -#if ENABLE_NLS - (void) setlocale (LC_MESSAGES, ""); - (void) bindtextdomain (PACKAGE, LOCALEDIR); - (void) textdomain (PACKAGE); -#endif - - g_message (_("Infinity commands:\n" - "- Space:\tchange effect.\n" - "- Tab:\t\ttoggle full-screen.\n" - "- Up/Down:\tup/down xmms main volume.\n" - "- Left/Right:\treward/forward actual played song, if any.\n" - "- z:\t\tprevious song.\n" - "- x:\t\tplay.\n" - "- c:\t\tpause.\n" - "- v:\t\tstop.\n" - "- b:\t\tnext song.\n" - "- Enter:\tswitch to interactive mode.\n\t\t(works only if infinity was configured with --enable-debug option)\n" - "- F11:\t\tscreenshot.\n" - "- F12:\t\tchange palette.")); - config_plugin_load_prefs (); - renderer_set_plugin_info (&sdlblur_vp); - renderer_init (); -} - - -static void plugin_close (void) -{ - config_plugin_save_prefs (); - renderer_finish (); -} - -static void dummy (GtkWidget *widget, gpointer data) -{ -} - -static void plugin_about (void) -{ - GtkWidget *window_about; - -#if ENABLE_NLS - (void) setlocale (LC_MESSAGES, ""); - (void) bindtextdomain (PACKAGE, LOCALEDIR); - (void) textdomain (PACKAGE); -#endif - - window_about = xmms_show_message (_("About Infinity"), - _("\n" PACKAGE_STRING "\n" - "\n\n" - "\nCopyright (C) 2000, Julien Carme.\n" - "Email: \n" - "\n" - "Duilio J. Protti \n" - "Actual maintainer\n" - "\n" - "This program is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with this program; if not, write to the Free Software\n" - "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\n" - "USA"), - _("Ok"), FALSE, dummy, NULL); - - gtk_widget_show (window_about); -} - - -/* - * - * Public functions - * - */ - - -/** - * Function to be exported to XMMS in order to register the plugin. - */ -VisPlugin *get_vplugin_info(void) -{ - return &sdlblur_vp; -} diff --git a/src/maintest.c b/src/maintest.c index 7951b4b..e2f4c9d 100644 --- a/src/maintest.c +++ b/src/maintest.c @@ -6,17 +6,17 @@ #include "main.h" #include "renderer.h" -gint32 playing, finished, reset,closed; +gint32 playing, finished, reset, closed; gint32 refreshed; gint16 pcm_data[2][512]; gint16 freq_data[2][256]; -gint32 pcm_count=0, freq_count=0; +gint32 pcm_count = 0, freq_count = 0; gint32 tr; -int main (int argc, char *argv[]) -{ - finished=FALSE; - closed=FALSE; +int main(int argc, char *argv[]) +{ + finished = FALSE; + closed = FALSE; /* mutex=SDL_CreateMutex(); */ /* FIXME check if there is MMX support here */ init_renderer(); diff --git a/src/mmx.h b/src/mmx.h index 7af2046..60bc5ac 100644 --- a/src/mmx.h +++ b/src/mmx.h @@ -1,166 +1,166 @@ /* mmx.h - - MultiMedia eXtensions GCC interface library for IA32. - - To use this library, simply include this header file - and compile with GCC. You MUST have inlining enabled - in order for mmx_ok() to work; this can be done by - simply using -O on the GCC command line. - - Compiling with -DMMX_TRACE will cause detailed trace - output to be sent to stderr for each mmx operation. - This adds lots of code, and obviously slows execution to - a crawl, but can be very useful for debugging. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT - LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR ANY PARTICULAR PURPOSE. - - 1997-99 by H. Dietz and R. Fisher - - Notes: - It appears that the latest gas has the pand problem fixed, therefore - I'll undefine BROKEN_PAND by default. -*/ + * + * MultiMedia eXtensions GCC interface library for IA32. + * + * To use this library, simply include this header file + * and compile with GCC. You MUST have inlining enabled + * in order for mmx_ok() to work; this can be done by + * simply using -O on the GCC command line. + * + * Compiling with -DMMX_TRACE will cause detailed trace + * output to be sent to stderr for each mmx operation. + * This adds lots of code, and obviously slows execution to + * a crawl, but can be very useful for debugging. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT + * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR ANY PARTICULAR PURPOSE. + * + * 1997-99 by H. Dietz and R. Fisher + * + * Notes: + * It appears that the latest gas has the pand problem fixed, therefore + * I'll undefine BROKEN_PAND by default. + */ #ifndef _MMX_H_ #define _MMX_H_ /* Warning: at this writing, the version of GAS packaged - with most Linux distributions does not handle the - parallel AND operation mnemonic correctly. If the - symbol BROKEN_PAND is defined, a slower alternative - coding will be used. If execution of mmxtest results - in an illegal instruction fault, define this symbol. -*/ -#undef BROKEN_PAND + * with most Linux distributions does not handle the + * parallel AND operation mnemonic correctly. If the + * symbol BROKEN_PAND is defined, a slower alternative + * coding will be used. If execution of mmxtest results + * in an illegal instruction fault, define this symbol. + */ +#undef BROKEN_PAND /* The type of an value that fits in an MMX register - (note that long long constant values MUST be suffixed - by LL and unsigned long long values by ULL, lest - they be truncated by the compiler) -*/ -typedef union { - gint64 q; /* Quadword (64-bit) value */ - guint64 uq; /* Unsigned Quadword */ - gint32 d[2]; /* 2 Doubleword (32-bit) values */ - guint32 ud[2]; /* 2 Unsigned Doubleword */ - gint16 w[4]; /* 4 Word (16-bit) values */ - guint16 uw[4]; /* 4 Unsigned Word */ - gchar b[8]; /* 8 Byte (8-bit) values */ - guchar ub[8]; /* 8 Unsigned Byte */ - gfloat s[2]; /* Single-precision (32-bit) value */ -} __attribute__ ((aligned (8))) mmx_t; /* On an 8-byte (64-bit) boundary */ + * (note that long long constant values MUST be suffixed + * by LL and unsigned long long values by ULL, lest + * they be truncated by the compiler) + */ +typedef union { + gint64 q; /* Quadword (64-bit) value */ + guint64 uq; /* Unsigned Quadword */ + gint32 d[2]; /* 2 Doubleword (32-bit) values */ + guint32 ud[2]; /* 2 Unsigned Doubleword */ + gint16 w[4]; /* 4 Word (16-bit) values */ + guint16 uw[4]; /* 4 Unsigned Word */ + gchar b[8]; /* 8 Byte (8-bit) values */ + guchar ub[8]; /* 8 Unsigned Byte */ + gfloat s[2]; /* Single-precision (32-bit) value */ +} __attribute__ ((aligned(8))) mmx_t; /* On an 8-byte (64-bit) boundary */ /* Helper functions for the instruction macros that follow... - (note that memory-to-register, m2r, instructions are nearly - as efficient as register-to-register, r2r, instructions; - however, memory-to-memory instructions are really simulated - as a convenience, and are only 1/3 as efficient) -*/ -#ifdef MMX_TRACE + * (note that memory-to-register, m2r, instructions are nearly + * as efficient as register-to-register, r2r, instructions; + * however, memory-to-memory instructions are really simulated + * as a convenience, and are only 1/3 as efficient) + */ +#ifdef MMX_TRACE /* Include the stuff for printing a trace to stderr... -*/ + */ #include -#define mmx_i2r(op, imm, reg) \ +#define mmx_i2r(op, imm, reg) \ { \ mmx_t mmx_trace; \ mmx_trace.uq = (imm); \ printf(#op "_i2r(" #imm "=0x%08x%08x, ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ ("movq %%" #reg ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#reg "=0x%08x%08x) => ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ : "X" (imm)); \ __asm__ __volatile__ ("movq %%" #reg ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#reg "=0x%08x%08x\n", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ } -#define mmx_m2r(op, mem, reg) \ +#define mmx_m2r(op, mem, reg) \ { \ mmx_t mmx_trace; \ mmx_trace = (mem); \ printf(#op "_m2r(" #mem "=0x%08x%08x, ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ ("movq %%" #reg ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#reg "=0x%08x%08x) => ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ : "X" (mem)); \ __asm__ __volatile__ ("movq %%" #reg ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#reg "=0x%08x%08x\n", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ } -#define mmx_r2m(op, reg, mem) \ +#define mmx_r2m(op, reg, mem) \ { \ mmx_t mmx_trace; \ __asm__ __volatile__ ("movq %%" #reg ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#op "_r2m(" #reg "=0x%08x%08x, ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ mmx_trace = (mem); \ printf(#mem "=0x%08x%08x) => ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ (#op " %%" #reg ", %0" \ : "=X" (mem) \ - : /* nothing */ ); \ + : /* nothing */); \ mmx_trace = (mem); \ printf(#mem "=0x%08x%08x\n", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ } -#define mmx_r2r(op, regs, regd) \ +#define mmx_r2r(op, regs, regd) \ { \ mmx_t mmx_trace; \ __asm__ __volatile__ ("movq %%" #regs ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#op "_r2r(" #regs "=0x%08x%08x, ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ ("movq %%" #regd ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#regd "=0x%08x%08x) => ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ (#op " %" #regs ", %" #regd); \ __asm__ __volatile__ ("movq %%" #regd ", %0" \ : "=X" (mmx_trace) \ - : /* nothing */ ); \ + : /* nothing */); \ printf(#regd "=0x%08x%08x\n", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ } -#define mmx_m2m(op, mems, memd) \ +#define mmx_m2m(op, mems, memd) \ { \ mmx_t mmx_trace; \ mmx_trace = (mems); \ printf(#op "_m2m(" #mems "=0x%08x%08x, ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ mmx_trace = (memd); \ printf(#memd "=0x%08x%08x) => ", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ __asm__ __volatile__ ("movq %0, %%mm0\n\t" \ #op " %1, %%mm0\n\t" \ "movq %%mm0, %0" \ @@ -168,33 +168,33 @@ typedef union { : "X" (mems)); \ mmx_trace = (memd); \ printf(#memd "=0x%08x%08x\n", \ - mmx_trace.d[1], mmx_trace.d[0]); \ + mmx_trace.d[1], mmx_trace.d[0]); \ } #else /* These macros are a lot simpler without the tracing... -*/ + */ -#define mmx_i2r(op, imm, reg) \ +#define mmx_i2r(op, imm, reg) \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ - : "X" (imm) ) + : "X" (imm)) -#define mmx_m2r(op, mem, reg) \ +#define mmx_m2r(op, mem, reg) \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ : "X" (mem)) -#define mmx_r2m(op, reg, mem) \ +#define mmx_r2m(op, reg, mem) \ __asm__ __volatile__ (#op " %%" #reg ", %0" \ : "=X" (mem) \ - : /* nothing */ ) + : /* nothing */) -#define mmx_r2r(op, regs, regd) \ +#define mmx_r2r(op, regs, regd) \ __asm__ __volatile__ (#op " %" #regs ", %" #regd) -#define mmx_m2m(op, mems, memd) \ +#define mmx_m2m(op, mems, memd) \ __asm__ __volatile__ ("movq %0, %%mm0\n\t" \ #op " %1, %%mm0\n\t" \ "movq %%mm0, %0" \ @@ -205,13 +205,13 @@ typedef union { /* 1x64 MOVe Quadword - (this is both a load and a store... - in fact, it is the only way to store) -*/ -#define movq_m2r(var, reg) mmx_m2r(movq, var, reg) -#define movq_r2m(reg, var) mmx_r2m(movq, reg, var) -#define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd) -#define movq(vars, vard) \ + * (this is both a load and a store... + * in fact, it is the only way to store) + */ +#define movq_m2r(var, reg) mmx_m2r(movq, var, reg) +#define movq_r2m(reg, var) mmx_r2m(movq, reg, var) +#define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd) +#define movq(vars, vard) \ __asm__ __volatile__ ("movq %1, %%mm0\n\t" \ "movq %%mm0, %0" \ : "=X" (vard) \ @@ -219,14 +219,14 @@ typedef union { /* 1x32 MOVe Doubleword - (like movq, this is both load and store... - but is most useful for moving things between - mmx registers and ordinary registers) -*/ -#define movd_m2r(var, reg) mmx_m2r(movd, var, reg) -#define movd_r2m(reg, var) mmx_r2m(movd, reg, var) -#define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd) -#define movd(vars, vard) \ + * (like movq, this is both load and store... + * but is most useful for moving things between + * mmx registers and ordinary registers) + */ +#define movd_m2r(var, reg) mmx_m2r(movd, var, reg) +#define movd_r2m(reg, var) mmx_r2m(movd, reg, var) +#define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd) +#define movd(vars, vard) \ __asm__ __volatile__ ("movd %1, %%mm0\n\t" \ "movd %%mm0, %0" \ : "=X" (vard) \ @@ -234,294 +234,294 @@ typedef union { /* 2x32, 4x16, and 8x8 Parallel ADDs -*/ -#define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg) -#define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd) -#define paddd(vars, vard) mmx_m2m(paddd, vars, vard) + */ +#define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg) +#define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd) +#define paddd(vars, vard) mmx_m2m(paddd, vars, vard) -#define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg) -#define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd) -#define paddw(vars, vard) mmx_m2m(paddw, vars, vard) +#define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg) +#define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd) +#define paddw(vars, vard) mmx_m2m(paddw, vars, vard) -#define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg) -#define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd) -#define paddb(vars, vard) mmx_m2m(paddb, vars, vard) +#define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg) +#define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd) +#define paddb(vars, vard) mmx_m2m(paddb, vars, vard) /* 4x16 and 8x8 Parallel ADDs using Saturation arithmetic -*/ -#define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg) -#define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd) -#define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard) + */ +#define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg) +#define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd) +#define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard) -#define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg) -#define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd) -#define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard) +#define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg) +#define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd) +#define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard) /* 4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic -*/ -#define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg) -#define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd) -#define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard) + */ +#define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg) +#define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd) +#define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard) -#define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg) -#define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd) -#define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard) +#define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg) +#define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd) +#define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard) /* 2x32, 4x16, and 8x8 Parallel SUBs -*/ -#define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg) -#define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd) -#define psubd(vars, vard) mmx_m2m(psubd, vars, vard) + */ +#define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg) +#define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd) +#define psubd(vars, vard) mmx_m2m(psubd, vars, vard) -#define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg) -#define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd) -#define psubw(vars, vard) mmx_m2m(psubw, vars, vard) +#define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg) +#define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd) +#define psubw(vars, vard) mmx_m2m(psubw, vars, vard) -#define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg) -#define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd) -#define psubb(vars, vard) mmx_m2m(psubb, vars, vard) +#define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg) +#define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd) +#define psubb(vars, vard) mmx_m2m(psubb, vars, vard) /* 4x16 and 8x8 Parallel SUBs using Saturation arithmetic -*/ -#define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg) -#define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd) -#define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard) + */ +#define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg) +#define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd) +#define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard) -#define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg) -#define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd) -#define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard) +#define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg) +#define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd) +#define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard) /* 4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic -*/ -#define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg) -#define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd) -#define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard) + */ +#define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg) +#define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd) +#define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard) -#define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg) -#define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd) -#define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard) +#define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg) +#define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd) +#define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard) /* 4x16 Parallel MULs giving Low 4x16 portions of results -*/ -#define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg) -#define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd) -#define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard) + */ +#define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg) +#define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd) +#define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard) /* 4x16 Parallel MULs giving High 4x16 portions of results -*/ -#define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg) -#define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd) -#define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard) + */ +#define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg) +#define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd) +#define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard) /* 4x16->2x32 Parallel Mul-ADD - (muls like pmullw, then adds adjacent 16-bit fields - in the multiply result to make the final 2x32 result) -*/ -#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg) -#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd) -#define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard) + * (muls like pmullw, then adds adjacent 16-bit fields + * in the multiply result to make the final 2x32 result) + */ +#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg) +#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd) +#define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard) /* 1x64 bitwise AND -*/ -#ifdef BROKEN_PAND -#define pand_m2r(var, reg) \ + */ +#ifdef BROKEN_PAND +#define pand_m2r(var, reg) \ { \ - mmx_m2r(pandn, (mmx_t) -1LL, reg); \ + mmx_m2r(pandn, (mmx_t)-1LL, reg); \ mmx_m2r(pandn, var, reg); \ } -#define pand_r2r(regs, regd) \ +#define pand_r2r(regs, regd) \ { \ - mmx_m2r(pandn, (mmx_t) -1LL, regd); \ + mmx_m2r(pandn, (mmx_t)-1LL, regd); \ mmx_r2r(pandn, regs, regd) \ } -#define pand(vars, vard) \ +#define pand(vars, vard) \ { \ movq_m2r(vard, mm0); \ - mmx_m2r(pandn, (mmx_t) -1LL, mm0); \ + mmx_m2r(pandn, (mmx_t)-1LL, mm0); \ mmx_m2r(pandn, vars, mm0); \ movq_r2m(mm0, vard); \ } #else -#define pand_m2r(var, reg) mmx_m2r(pand, var, reg) -#define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd) -#define pand(vars, vard) mmx_m2m(pand, vars, vard) +#define pand_m2r(var, reg) mmx_m2r(pand, var, reg) +#define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd) +#define pand(vars, vard) mmx_m2m(pand, vars, vard) #endif /* 1x64 bitwise AND with Not the destination -*/ -#define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg) -#define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd) -#define pandn(vars, vard) mmx_m2m(pandn, vars, vard) + */ +#define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg) +#define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd) +#define pandn(vars, vard) mmx_m2m(pandn, vars, vard) /* 1x64 bitwise OR -*/ -#define por_m2r(var, reg) mmx_m2r(por, var, reg) -#define por_r2r(regs, regd) mmx_r2r(por, regs, regd) -#define por(vars, vard) mmx_m2m(por, vars, vard) + */ +#define por_m2r(var, reg) mmx_m2r(por, var, reg) +#define por_r2r(regs, regd) mmx_r2r(por, regs, regd) +#define por(vars, vard) mmx_m2m(por, vars, vard) /* 1x64 bitwise eXclusive OR -*/ -#define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg) -#define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd) -#define pxor(vars, vard) mmx_m2m(pxor, vars, vard) + */ +#define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg) +#define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd) +#define pxor(vars, vard) mmx_m2m(pxor, vars, vard) /* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality - (resulting fields are either 0 or -1) -*/ -#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg) -#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd) -#define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard) + * (resulting fields are either 0 or -1) + */ +#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg) +#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd) +#define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard) -#define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg) -#define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd) -#define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard) +#define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg) +#define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd) +#define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard) -#define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg) -#define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd) -#define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard) +#define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg) +#define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd) +#define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard) /* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than - (resulting fields are either 0 or -1) -*/ -#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg) -#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd) -#define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard) + * (resulting fields are either 0 or -1) + */ +#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg) +#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd) +#define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard) -#define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg) -#define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd) -#define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard) +#define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg) +#define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd) +#define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard) -#define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg) -#define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd) -#define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard) +#define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg) +#define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd) +#define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard) /* 1x64, 2x32, and 4x16 Parallel Shift Left Logical -*/ -#define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg) -#define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg) -#define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd) -#define psllq(vars, vard) mmx_m2m(psllq, vars, vard) + */ +#define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg) +#define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg) +#define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd) +#define psllq(vars, vard) mmx_m2m(psllq, vars, vard) -#define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg) -#define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg) -#define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd) -#define pslld(vars, vard) mmx_m2m(pslld, vars, vard) +#define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg) +#define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg) +#define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd) +#define pslld(vars, vard) mmx_m2m(pslld, vars, vard) -#define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg) -#define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg) -#define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd) -#define psllw(vars, vard) mmx_m2m(psllw, vars, vard) +#define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg) +#define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg) +#define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd) +#define psllw(vars, vard) mmx_m2m(psllw, vars, vard) /* 1x64, 2x32, and 4x16 Parallel Shift Right Logical -*/ -#define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg) -#define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg) -#define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd) -#define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard) + */ +#define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg) +#define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg) +#define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd) +#define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard) -#define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg) -#define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg) -#define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd) -#define psrld(vars, vard) mmx_m2m(psrld, vars, vard) +#define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg) +#define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg) +#define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd) +#define psrld(vars, vard) mmx_m2m(psrld, vars, vard) -#define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg) -#define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg) -#define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd) -#define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard) +#define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg) +#define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg) +#define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd) +#define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard) /* 2x32 and 4x16 Parallel Shift Right Arithmetic -*/ -#define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg) -#define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg) -#define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd) -#define psrad(vars, vard) mmx_m2m(psrad, vars, vard) + */ +#define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg) +#define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg) +#define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd) +#define psrad(vars, vard) mmx_m2m(psrad, vars, vard) -#define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg) -#define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg) -#define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd) -#define psraw(vars, vard) mmx_m2m(psraw, vars, vard) +#define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg) +#define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg) +#define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd) +#define psraw(vars, vard) mmx_m2m(psraw, vars, vard) /* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate - (packs source and dest fields into dest in that order) -*/ -#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg) -#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd) -#define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard) + * (packs source and dest fields into dest in that order) + */ +#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg) +#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd) +#define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard) -#define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg) -#define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd) -#define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard) +#define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg) +#define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd) +#define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard) /* 4x16->8x8 PACK and Unsigned Saturate - (packs source and dest fields into dest in that order) -*/ -#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg) -#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd) -#define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard) + * (packs source and dest fields into dest in that order) + */ +#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg) +#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd) +#define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard) /* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low - (interleaves low half of dest with low half of source - as padding in each result field) -*/ -#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg) -#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd) -#define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard) + * (interleaves low half of dest with low half of source + * as padding in each result field) + */ +#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg) +#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd) +#define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard) -#define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg) -#define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd) -#define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard) +#define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg) +#define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd) +#define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard) -#define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg) -#define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd) -#define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard) +#define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg) +#define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd) +#define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard) /* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High - (interleaves high half of dest with high half of source - as padding in each result field) -*/ -#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg) -#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd) -#define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard) + * (interleaves high half of dest with high half of source + * as padding in each result field) + */ +#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg) +#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd) +#define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard) -#define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg) -#define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd) -#define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard) +#define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg) +#define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd) +#define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard) -#define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg) -#define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd) -#define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard) +#define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg) +#define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd) +#define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard) /* Empty MMx State - (used to clean-up when going from mmx to float use - of the registers that are shared by both; note that - there is no float-to-mmx operation needed, because - only the float tag word info is corruptible) -*/ -#ifdef MMX_TRACE + * (used to clean-up when going from mmx to float use + * of the registers that are shared by both; note that + * there is no float-to-mmx operation needed, because + * only the float tag word info is corruptible) + */ +#ifdef MMX_TRACE -#define emms() \ +#define emms() \ { \ printf("emms()\n"); \ __asm__ __volatile__ ("emms"); \ @@ -529,7 +529,7 @@ typedef union { #else -#define emms() __asm__ __volatile__ ("emms") +#define emms() __asm__ __volatile__ ("emms") #endif diff --git a/src/renderer.c b/src/renderer.c index 4553eb8..2be7f3d 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -12,7 +12,7 @@ * 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. -*/ + */ #include #include #include @@ -42,13 +42,13 @@ #include "cputest.h" #endif -#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) -#define next_effect() (t_last_effect += 1) -#define next_color() (t_last_color += 1) +#define wrap(a) (a < 0 ? 0 : (a > 255 ? 255 : a)) +#define next_effect() (t_last_effect++) +#define next_color() (t_last_color++) typedef struct t_general_parameters { - gint32 t_between_effects; - gint32 t_between_colors; + gint32 t_between_effects; + gint32 t_between_colors; } t_general_parameters; typedef gint32 t_color; @@ -75,32 +75,31 @@ static GTimer *title_timer; static SDL_Thread *thread; -static DBusGConnection * connection = NULL; -static DBusGProxy * dbus_proxy = NULL; +static DBusGConnection *connection = NULL; +static DBusGProxy *dbus_proxy = NULL; -static gint32 event_filter (const SDL_Event *event); -static void check_events (); -static int renderer (void *); +static gint32 event_filter(const SDL_Event *event); +static void check_events(); +static int renderer(void *); #if MMX_DETECTION -static int renderer_mmx (void *); +static int renderer_mmx(void *); #endif -static void set_title (void); +static void set_title(void); /* * Public functions */ - -void renderer_init (void) +void renderer_init(void) { - GError * error = NULL; + GError *error = NULL; gint32 try; - + if (initializing) { - g_warning (_("We are already initializing")); + g_warning(_("We are already initializing")); try = 0; while (initializing) { - g_usleep (1000000); - (void) sleep (1); + g_usleep(1000000); + (void)sleep(1); if (try++ > 10) return; } @@ -109,67 +108,67 @@ void renderer_init (void) scr_par.width = config_get_xres(); scr_par.height = config_get_yres(); scr_par.scale = config_get_sres(); - + gen_par.t_between_effects = config_get_teff(); gen_par.t_between_colors = config_get_tcol(); - + old_color = 0; color = 0; - + finished = FALSE; must_resize = FALSE; resizing = FALSE; - resizing_mutex = SDL_CreateMutex (); + resizing_mutex = SDL_CreateMutex(); mode_interactif = FALSE; visible = TRUE; quiting = FALSE; first_xevent = TRUE; - display_init (); - current_title = g_strdup ("Infinity"); + display_init(); + current_title = g_strdup("Infinity"); set_title(); - title_timer = g_timer_new (); - g_timer_start (title_timer); - display_load_random_effect (¤t_effect); - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - dbus_proxy = dbus_g_proxy_new_for_name (connection, AUDACIOUS_DBUS_SERVICE, - AUDACIOUS_DBUS_PATH, - AUDACIOUS_DBUS_INTERFACE); + title_timer = g_timer_new(); + g_timer_start(title_timer); + display_load_random_effect(¤t_effect); + + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE, + AUDACIOUS_DBUS_PATH, + AUDACIOUS_DBUS_INTERFACE); + + (void)SDL_EventState((Uint8)SDL_ALLEVENTS, SDL_IGNORE); + (void)SDL_EventState((Uint8)SDL_VIDEORESIZE, SDL_ENABLE); + (void)SDL_EventState((Uint8)SDL_ACTIVEEVENT, SDL_ENABLE); + (void)SDL_EventState((Uint8)SDL_KEYDOWN, SDL_ENABLE); + (void)SDL_EventState((Uint8)SDL_QUIT, SDL_ENABLE); + + SDL_SetEventFilter(event_filter); - (void) SDL_EventState ((Uint8) SDL_ALLEVENTS, SDL_IGNORE); - (void) SDL_EventState ((Uint8) SDL_VIDEORESIZE, SDL_ENABLE); - (void) SDL_EventState ((Uint8) SDL_ACTIVEEVENT, SDL_ENABLE); - (void) SDL_EventState ((Uint8) SDL_KEYDOWN, SDL_ENABLE); - (void) SDL_EventState ((Uint8) SDL_QUIT, SDL_ENABLE); - - SDL_SetEventFilter (event_filter); - #if MMX_DETECTION - if (mm_support_check_and_show () != 0) - thread = SDL_CreateThread (renderer_mmx,NULL); + if (mm_support_check_and_show() != 0) + thread = SDL_CreateThread(renderer_mmx, NULL); else #endif - thread = SDL_CreateThread (renderer,NULL); + thread = SDL_CreateThread(renderer, NULL); } -void renderer_finish (void) +void renderer_finish(void) { gint32 try; - + if (initializing) { - g_warning (_("The plugin have not yet initialized")); + g_warning(_("The plugin have not yet initialized")); try = 0; while (initializing) { - g_usleep (1000000); + g_usleep(1000000); if (try++ > 10) return; } } quiting = TRUE; finished = TRUE; - SDL_WaitThread (thread, NULL); - SDL_DestroyMutex (resizing_mutex); + SDL_WaitThread(thread, NULL); + SDL_DestroyMutex(resizing_mutex); /* * Take some time to let it know renderer_render_multi_pcm() * that must not call display_set_pcm_data(). @@ -180,41 +179,40 @@ void renderer_finish (void) * * See display.h::display_set_pcm_data() */ - g_usleep (10000*SDL_TIMESLICE); - display_quit (); - g_timer_destroy (title_timer); - g_object_unref (dbus_proxy); - g_message ("Infinity: Closing..."); + g_usleep(10000 * SDL_TIMESLICE); + display_quit(); + g_timer_destroy(title_timer); + g_object_unref(dbus_proxy); + g_message("Infinity: Closing..."); } -void renderer_render_multi_pcm (const float * data, int channels) +void renderer_render_multi_pcm(const float *data, int channels) { if (!initializing && !quiting) - display_set_pcm_data (data, channels); + display_set_pcm_data(data, channels); } /* * Private functions */ - -static gint32 event_filter (const SDL_Event *event) +static gint32 event_filter(const SDL_Event *event) { if (!event) { - g_warning ("Infinity: SDL_Event is NULL"); + g_warning("Infinity: SDL_Event is NULL"); return 0; } switch (event->type) { case SDL_VIDEORESIZE: - g_return_val_if_fail (SDL_LockMutex (resizing_mutex) >= 0, 0); + g_return_val_if_fail(SDL_LockMutex(resizing_mutex) >= 0, 0); if (resizing) { - g_return_val_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0, 0); + g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, 0); /* * VIDEORESIZE event dropped from event queue */ return 0; } else { - g_return_val_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0, 0); + g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, 0); return 1; } g_assert_not_reached(); @@ -240,92 +238,91 @@ static gint32 event_filter (const SDL_Event *event) return 1; } -static gint disable_func (gpointer data) +static gint disable_func(gpointer data) { renderer_finish(); return FALSE; } -static void check_events () +static void check_events() { SDL_Event event; gint volume; /*XEvent *xevent; - XWindowChanges changes; - XWindowAttributes attr; - XSetWindowAttributes s_attr;*/ + * XWindowChanges changes; + * XWindowAttributes attr; + * XSetWindowAttributes s_attr;*/ if (config_get_show_title()) { - if (g_timer_elapsed (title_timer, NULL) > 1.0) { - if (aud_drct_get_playing () && aud_drct_get_ready ()) { + if (g_timer_elapsed(title_timer, NULL) > 1.0) { + if (aud_drct_get_playing() && aud_drct_get_ready()) { if (current_title) - g_free (current_title); - current_title = g_strdup (aud_playlist_entry_get_title(aud_playlist_get_playing (), aud_playlist_get_position(aud_playlist_get_playing ()), FALSE)); + g_free(current_title); + current_title = g_strdup(aud_playlist_entry_get_title(aud_playlist_get_playing(), aud_playlist_get_position(aud_playlist_get_playing()), FALSE)); + set_title(); + } else { + if (current_title) + g_free(current_title); + current_title = g_strdup("Infinity"); set_title(); } - else { - if (current_title) - g_free (current_title); - current_title = g_strdup ("Infinity"); - set_title(); - } - g_timer_reset (title_timer); + g_timer_reset(title_timer); } } - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { - /*case SDL_SYSWMEVENT: - g_message ("Infinity: SDL_SYSWMEVENT"); - if (event.syswm.msg != NULL) { - if (event.syswm.msg->subsystem == SDL_SYSWM_X11) { - xevent = &(event.syswm.msg->event.xevent); - if (xevent == NULL) - continue; - if (first_xevent) { - changes.x = config_get_x(); - changes.y = config_get_y(); - XConfigureWindow (xevent->xany.display, - xevent->xany.window, - CWX | CWY, &changes); - first_xevent = FALSE; - g_message ("Infinity: window moved to (%d,%d)", - changes.x, changes.y); - } else { - XGetWindowAttributes (xevent->xany.display, - xevent->xany.window, - &attr); - g_message ("Infinity: GetWindowAttributes (%d,%d)", - attr.x, attr.y); - } - } - } - break;*/ + /*case SDL_SYSWMEVENT: + * g_message ("Infinity: SDL_SYSWMEVENT"); + * if (event.syswm.msg != NULL) { + * if (event.syswm.msg->subsystem == SDL_SYSWM_X11) { + * xevent = &(event.syswm.msg->event.xevent); + * if (xevent == NULL) + * continue; + * if (first_xevent) { + * changes.x = config_get_x(); + * changes.y = config_get_y(); + * XConfigureWindow (xevent->xany.display, + * xevent->xany.window, + * CWX | CWY, &changes); + * first_xevent = FALSE; + * g_message ("Infinity: window moved to (%d,%d)", + * changes.x, changes.y); + * } else { + * XGetWindowAttributes (xevent->xany.display, + * xevent->xany.window, + * &attr); + * g_message ("Infinity: GetWindowAttributes (%d,%d)", + * attr.x, attr.y); + * } + * } + * } + * break;*/ case SDL_QUIT: - GDK_THREADS_ENTER (); - (void) gtk_idle_add (disable_func, NULL); - GDK_THREADS_LEAVE (); - break; + GDK_THREADS_ENTER(); + (void)gtk_idle_add(disable_func, NULL); + GDK_THREADS_LEAVE(); + break; case SDL_VIDEORESIZE: - g_return_if_fail (SDL_LockMutex (resizing_mutex) >= 0); + g_return_if_fail(SDL_LockMutex(resizing_mutex) >= 0); resizing = TRUE; - g_return_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0); + g_return_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0); scr_par.width = event.resize.w; scr_par.height = event.resize.h; - g_message ("Infinity: Screen resized to %dx%d pixels^2", - scr_par.width, scr_par.height); + g_message("Infinity: Screen resized to %dx%d pixels^2", + scr_par.width, scr_par.height); must_resize = TRUE; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_RIGHT: - if (aud_drct_get_playing () && aud_drct_get_ready ()) - aud_drct_seek (aud_drct_get_time () + 5000); + if (aud_drct_get_playing() && aud_drct_get_ready()) + aud_drct_seek(aud_drct_get_time() + 5000); break; case SDLK_LEFT: - if (aud_drct_get_playing () && aud_drct_get_ready ()) - aud_drct_seek (aud_drct_get_time () - 5000); + if (aud_drct_get_playing() && aud_drct_get_ready()) + aud_drct_seek(aud_drct_get_time() - 5000); break; case SDLK_UP: aud_drct_get_volume_main(&volume); @@ -338,7 +335,7 @@ static void check_events () aud_drct_set_volume_main(volume - 5); break; case SDLK_TAB: - display_toggle_fullscreen (); + display_toggle_fullscreen(); break; case SDLK_z: aud_drct_pl_prev(); @@ -356,17 +353,17 @@ static void check_events () aud_drct_pl_next(); break; case SDLK_F11: - display_save_screen (); + display_save_screen(); break; case SDLK_F12: - if (t_last_color>32) { + if (t_last_color > 32) { t_last_color = 0; old_color = color; - color = (color + 1) % NB_PALETTES; + color = ++color % NB_PALETTES; } break; case SDLK_SPACE: - display_load_random_effect (¤t_effect); + display_load_random_effect(¤t_effect); t_last_effect = 0; break; #ifdef INFINITY_DEBUG @@ -386,21 +383,21 @@ static void check_events () if (mode_interactif) { gint32 i; gint32 sx, sy; - byte* keystate; + byte *keystate; keystate = SDL_GetKeyState(NULL); - SDL_GetMouseState (&sx, &sy); + SDL_GetMouseState(&sx, &sy); current_effect.spectral_shift = sx; - if ( keystate[SDLK_a]) - current_effect.curve_color = wrap (current_effect.curve_color - 32); - if ( keystate[SDLK_z]) - current_effect.curve_color = wrap (current_effect.curve_color + 32); - if ( keystate[SDLK_q]) - current_effect.spectral_color = wrap (current_effect.spectral_color - 32); - if ( keystate[SDLK_s]) - current_effect.spectral_color = wrap (current_effect.spectral_color + 32); + if (keystate[SDLK_a]) + current_effect.curve_color = wrap(current_effect.curve_color - 32); + if (keystate[SDLK_z]) + current_effect.curve_color = wrap(current_effect.curve_color + 32); + if (keystate[SDLK_q]) + current_effect.spectral_color = wrap(current_effect.spectral_color - 32); + if (keystate[SDLK_s]) + current_effect.spectral_color = wrap(current_effect.spectral_color + 32); for (i = 0; i < 10; i++) - if ( keystate[SDLK_F1 + i]) + if (keystate[SDLK_F1 + i]) current_effect.num_effect = i % NB_FCT; if (keystate[SDLK_d]) current_effect.spectral_amplitude = (current_effect.spectral_amplitude - 1); @@ -410,15 +407,15 @@ static void check_events () current_effect.curve_amplitude = (current_effect.curve_amplitude - 1); if (keystate[SDLK_r]) current_effect.curve_amplitude = (current_effect.curve_amplitude + 1); - if ( keystate[SDLK_m]) - display_save_effect (¤t_effect); - if ( keystate[SDLK_w]) + if (keystate[SDLK_m]) + display_save_effect(¤t_effect); + if (keystate[SDLK_w]) current_effect.mode_spectre = (current_effect.mode_spectre + 1) % 5; } -#endif /* INFINITY_DEBUG */ +#endif /* INFINITY_DEBUG */ } -static int renderer (void *arg) +static int renderer(void *arg) { gint32 render_time, now; gint32 frame_length; @@ -428,45 +425,44 @@ static int renderer (void *arg) /* We suppose here that config module have been initialized */ fps = config_get_fps(); frame_length = (gint32)((1.0 / config_get_fps()) * 1000); - g_message ("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); + g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); initializing = FALSE; - for (;;) { /* ever... */ + for (;; ) { /* ever... */ if (!visible) { - check_events (); + check_events(); if (finished) break; - g_usleep (3000*frame_length); + g_usleep(3000 * frame_length); continue; } check_events(); if (finished) break; if (must_resize) { - display_resize (scr_par.width, scr_par.height); - config_set_xres (scr_par.width); - config_set_yres (scr_par.height); + display_resize(scr_par.width, scr_par.height); + config_set_xres(scr_par.width); + config_set_yres(scr_par.height); must_resize = FALSE; - g_return_val_if_fail (SDL_LockMutex (resizing_mutex) >= 0, -1); + g_return_val_if_fail(SDL_LockMutex(resizing_mutex) >= 0, -1); resizing = FALSE; - g_return_val_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0, -1); + g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1); } - render_time = (gint32) SDL_GetTicks (); - display_blur (scr_par.width*scr_par.height*current_effect.num_effect); - spectral (¤t_effect); - curve (¤t_effect); - if (t_last_color <= 32) { - change_color (old_color, color, t_last_color*8); - } - next_color (); - next_effect (); + render_time = (gint32)SDL_GetTicks(); + display_blur(scr_par.width * scr_par.height * current_effect.num_effect); + spectral(¤t_effect); + curve(¤t_effect); + if (t_last_color <= 32) + change_color(old_color, color, t_last_color * 8); + next_color(); + next_effect(); if (t_last_effect % gen_par.t_between_effects == 0) { #ifdef INFINITY_DEBUG if (!mode_interactif) { - display_load_random_effect (¤t_effect); + display_load_random_effect(¤t_effect); t_last_effect = 0; } #else - display_load_random_effect (¤t_effect); + display_load_random_effect(¤t_effect); t_last_effect = 0; #endif } @@ -488,19 +484,19 @@ static int renderer (void *arg) if (new_fps != fps) { fps = new_fps; frame_length = (gint32)(((1.0 / fps) * 1000)); - g_message ("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); + g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); } - now = (gint32) SDL_GetTicks (); + now = (gint32)SDL_GetTicks(); if ((idle_time = (now - render_time)) < frame_length) - g_usleep (idle_time*900); + g_usleep(idle_time * 900); } return 0; } #if MMX_DETECTION -static int renderer_mmx (void *arg) +static int renderer_mmx(void *arg) { gint32 render_time, now; gint32 frame_length; @@ -510,45 +506,44 @@ static int renderer_mmx (void *arg) /* We suppose here that config module have been initialized */ fps = config_get_fps(); frame_length = ((1.0 / fps) * 1000); - g_message ("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); + g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); initializing = FALSE; - for (;;) { /* ever... */ + for (;; ) { /* ever... */ if (!visible) { - check_events (); + check_events(); if (finished) break; - g_usleep (3000*frame_length); + g_usleep(3000 * frame_length); continue; } - check_events (); + check_events(); if (finished) break; if (must_resize) { - display_resize (scr_par.width, scr_par.height); - config_set_xres (scr_par.width); - config_set_yres (scr_par.height); + display_resize(scr_par.width, scr_par.height); + config_set_xres(scr_par.width); + config_set_yres(scr_par.height); must_resize = FALSE; - g_return_val_if_fail (SDL_LockMutex (resizing_mutex) >= 0, -1); + g_return_val_if_fail(SDL_LockMutex(resizing_mutex) >= 0, -1); resizing = FALSE; - g_return_val_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0, -1); + g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1); } - render_time = SDL_GetTicks (); - display_blur_mmx (scr_par.width * scr_par.height * current_effect.num_effect); - spectral (¤t_effect); - curve (¤t_effect); - if (t_last_color <= 32) { - change_color (old_color, color, t_last_color*8); - } - next_color (); - next_effect (); + render_time = SDL_GetTicks(); + display_blur_mmx(scr_par.width * scr_par.height * current_effect.num_effect); + spectral(¤t_effect); + curve(¤t_effect); + if (t_last_color <= 32) + change_color(old_color, color, t_last_color * 8); + next_color(); + next_effect(); if (t_last_effect % gen_par.t_between_effects == 0) { #ifdef INFINITY_DEBUG if (!mode_interactif) { - display_load_random_effect (¤t_effect); + display_load_random_effect(¤t_effect); t_last_effect = 0; } #else - display_load_random_effect (¤t_effect); + display_load_random_effect(¤t_effect); t_last_effect = 0; #endif } @@ -570,20 +565,19 @@ static int renderer_mmx (void *arg) if (new_fps != fps) { fps = new_fps; frame_length = ((1.0 / fps) * 1000); - g_message ("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); + g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", __LINE__, fps); } - now = SDL_GetTicks (); + now = SDL_GetTicks(); if ((idle_time = (now - render_time)) < frame_length) - g_usleep (idle_time*900); + g_usleep(idle_time * 900); } return 0; } #endif /* MMX_DETECTION */ -static void set_title (void) +static void set_title(void) { - SDL_WM_SetCaption (current_title, "Infinity"); + SDL_WM_SetCaption(current_title, "Infinity"); } - diff --git a/src/renderer.h b/src/renderer.h index a37d4dd..40f1a6e 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -19,8 +19,8 @@ * 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. -*/ -#ifndef __INFINITY_RENDERER__ + */ +#ifndef __INFINITY_RENDERER__ #define __INFINITY_RENDERER__ #include @@ -31,18 +31,18 @@ * Reads configuration parameters and launchs a thread where most of the * plugin job gets done. */ -void renderer_init (void); +void renderer_init(void); /** * Closes rendering process. */ -void renderer_finish (void); +void renderer_finish(void); /** * Copies PCM data from Audacity. * * Called periodically by Audacity with actual PCM data. */ -void renderer_render_multi_pcm (const float * data, int channels); +void renderer_render_multi_pcm(const float *data, int channels); #endif /* __INFINITY_RENDERER__ */ diff --git a/src/spectrum.c b/src/spectrum.c deleted file mode 100644 index 8900bae..0000000 --- a/src/spectrum.c +++ /dev/null @@ -1,396 +0,0 @@ -#include -#include -/*#include "libxmms/util.h"*/ -#include - -#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) -#define PI 3.14159 - -#define WIDTH 400 -#define HEIGHT 300 - - -#define INTERPOLATION 0 //0 or 1 to double resolution. -#define NB_FCT 6 -#define NB_PALETTES 5 - -#include "affiche.h" - -#define PERIODE_COLORS 64 -#define PERIODE_EFFECTS 128 - -#define VIDEO_FLAGS (SDL_HWSURFACE|SDL_HWPALETTE) - -#define BASS_EXT_MEMORY 100 - -typedef guchar byte; - -static void sanalyzer_init(void); - -static void sanalyzer_cleanup(void); -static void sanalyzer_playback_start(void); -static void sanalyzer_playback_stop(void); -static void sanalyzer_render_pcm(gint16 data[2][512]); -static void sanalyzer_render_freq(gint16 data[2][256]); - -/* -typedef struct coord { - int x,y; -} coord; - -typedef struct complex { - float x,y; -} complex; - -typedef struct interpol { - coord c; //coordinates of the top left pixel. - int w1,w2,w3,w4; -} interpol; - -typedef struct effect { - int addr_effect; - int f1,f2,f3; - int x_curve; - int p_speed,p_rotation; - int color,old_color; - int curve_color; - int spectral_color; - int mode_spectre; - int spectral_shift; - int flash; -} effect; -*/ -struct bass_info { - //int mem[SIZE_BASS_MEM]; - gint32 max_recent; - gint32 max_old; - gint32 time_last_max; - gint32 min_recent; - gint32 min_old; - gint32 time_last_min; - gint32 activated; -} bass_info; - - - -interpol vector_field[NB_FCT][WIDTH*HEIGHT]; - -effect current_effect; - -gint32 t=0; - -VisPlugin sanalyzer_vp = -{ - NULL, - NULL, - - 0, - "Simple spectrum analyzer", - 1, - 1, - sanalyzer_init, - sanalyzer_cleanup, - NULL, - NULL, - NULL, - sanalyzer_playback_start, - sanalyzer_playback_stop, - sanalyzer_render_pcm, - sanalyzer_render_freq -}; - -VisPlugin *get_vplugin_info(void) -{ - return &sanalyzer_vp; -} - -complex fct(complex a,gint32 n,gint32 p1,gint32 p2) //p1 et p2:0-4 -{ - complex b,b1,b2; - gfloat fact; - gfloat an; - gfloat circle_size; - gfloat speed; - gfloat co,si; - - a.x-=WIDTH/2; - a.y-=HEIGHT/2; - - switch (n) { - - case 0: - an=0.025*(p1-2)+0.002; - co=cos(an); - si=sin(an); - circle_size=HEIGHT*0.25; - speed=2000+p2*500; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - - case 1: - an=0.015*(p1-2)+0.002; - co=cos(an); - si=sin(an); - circle_size=HEIGHT*0.45; - speed=4000+p2*1000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - - case 2: - an=0.002; - co=cos(an); - si=sin(an); - circle_size=HEIGHT*0.25; - speed=400+p2*100; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - - case 3: - an=(sin(sqrt(a.x*a.x+a.y*a.y)/20)/20)+0.002; - co=cos(an); - si=sin(an); - circle_size=HEIGHT*0.25; - speed=4000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - - case 4: - an=0.002; - co=cos(an); - si=sin(an); - circle_size=HEIGHT*0.25; - speed=sin(sqrt(a.x*a.x+a.y*a.y)/5)*3000+4000; - b.x=(co*a.x-si*a.y); - b.y=(si*a.x+co*a.y); - fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1; - b.x=(b.x*fact); - b.y=(b.y*fact); - break; - - case 5: - b.x=a.x*1.0; - b.y=a.y*1.0; - - } - - b.x+=WIDTH/2; - b.y+=HEIGHT/2; - if (b.x<0) - b.x=0; - if (b.y<0) - b.y=0; - if (b.x>WIDTH-1) - b.x=WIDTH-1; - if (b.y>HEIGHT-1) - b.y=HEIGHT-1; - - return b; -} - - -void generate_sector(gint32 g,gint32 f,gint32 p1,gint32 p2,gint32 debut,gint32 step) -{ - coord c; - complex a; - gfloat fpy; - gint32 rw,lw,add; - gint32 fin=debut+step; - gint32 prop_transmitted=249; - gint32 i,j; - - if (fin>HEIGHT) - fin=HEIGHT; - for (c.y=debut;c.y>4)+(data[1][i]>>4); - - bass=bass/step/2; - - if (bass>bass_info.max_recent) - bass_info.max_recent=bass; - - if (bassBASS_EXT_MEMORY) { - bass_info.max_old=bass_info.max_recent; - bass_info.max_recent=0; - bass_info.time_last_max=t; - } - - if (t-bass_info.time_last_min>BASS_EXT_MEMORY) { - bass_info.min_old=bass_info.min_recent; - bass_info.min_recent=0; - bass_info.time_last_min=t; - } - - if (bass>(bass_info.max_old*6+bass_info.min_old*4)/10 && bass_info.activated==0) { - if (current_effect.flash) - flash(255,t); - bass_info.activated=1; - } - - if (bass<(bass_info.max_old*4+bass_info.min_old*6)/10 && bass_info.activated==1) - bass_info.activated=0; -} - -void sanalyzer_render_pcm(gint16 data[2][512]) -{ - SDL_Event event; - Uint8 *keystate; - gint32 son=0; - gint32 trace=0; - gfloat x,y,v,vr; - gint32 i; - gint32 t_last_palette=0; - - while ( SDL_PollEvent(&event) ) { - if ( event.type == SDL_QUIT ) - SDL_Quit(); - if (event.type == SDL_KEYDOWN) { - gchar *st; - st=SDL_GetKeyName(event.key.keysym.sym); - if (!strcmp(st,"a")) - current_effect.curve_color=wrap(current_effect.curve_color-32); - if (!strcmp(st,"z")) - current_effect.curve_color=wrap(current_effect.curve_color+32); - if (!strcmp(st,"q")) - current_effect.spectral_color=wrap(current_effect.spectral_color-32); - if (!strcmp(st,"s")) - current_effect.spectral_color=wrap(current_effect.spectral_color+32); - if (!strcmp(st,"w")) - current_effect.mode_spectre=(current_effect.mode_spectre+1)%5; - if (!strcmp(st,"x")) - current_effect.flash=(current_effect.flash+1)%2; - } - } - - keystate = SDL_GetKeyState(NULL); - if ( keystate[SDLK_ESCAPE] ) - ToggleFullScreen(); - for (i=0;i<10;i++) - if ( keystate[SDLK_F1+i]) - current_effect.addr_effect=i%NB_FCT; - if (keystate[SDLK_F11]) { - current_effect.color=(current_effect.color-1)%NB_PALETTES; - t_last_palette=0; - } - if (keystate[SDLK_F12]) { - current_effect.color=(current_effect.color+1)%NB_PALETTES; - t_last_palette=0; - } - if (keystate[SDLK_e]) { - current_effect.spectral_shift=(current_effect.spectral_shift-10)%HEIGHT; - } - if (keystate[SDLK_r]) { - current_effect.spectral_shift=(current_effect.spectral_shift+10)%HEIGHT; - } - - if (t_last_palette<8) - change_color(current_effect.color,(current_effect.color+1)%NB_PALETTES,(t_last_palette+1)*32); - /* - if (t%PERIODE_EFFECTS==0) { - // while (current_effect.f1==current_effect.f2) { - // current_effect.f2=current_effect.f1; - //current_effect.f1=rand()%NB_TYPE_FCT; - //} - //current_effect.p_rotation=2; - //current_effect.p_speed=rand()%5; - current_effect.addr_effect=(current_effect.addr_effect+1)%NB_FCT; - }*/ - /* - generate_sector(1-current_effect.addr_effect,current_effect.f1, - current_effect.p_rotation,current_effect.p_speed, - (t%PERIODE_EFFECTS)*(HEIGHT/PERIODE_EFFECTS+1), - (HEIGHT/PERIODE_EFFECTS+1)); - */ - affiche(current_effect.addr_effect,vector_field); - - spectral(data,current_effect); - - curve(¤t_effect); - - t+=1; - t_last_palette+=1; -} diff --git a/src/types.h b/src/types.h index a26969d..808f306 100644 --- a/src/types.h +++ b/src/types.h @@ -18,8 +18,8 @@ * 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. -*/ -#ifndef __INFINITY_TYPES__ + */ +#ifndef __INFINITY_TYPES__ #define __INFINITY_TYPES__ #include