/* scivi - visualization plugin for XMMS * Copyright (C) 2003 Vitaly V. Bursov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DYNAM_H #define DYNAM_H #include "presets.h" typedef union { int i; float f; } Code; enum { NOP, /* CONSTANTS */ C_ONE, C_ZERO, C_HALF, /* OPERATORS */ /* UNARY */ FLOAT, NEGATE, VAR_GET, NOT, LNOT, /* BINRARY */ PLUS, MINUS, DIVIDE, MOD, MULTIPLY, OR, OROR, AND, ANDAND, XOR, GREAT, LESS, GREAT_EQ, LESS_EQ, EQUAL, NEQUAL, VAR_SET, VAR_SET_PLUS, VAR_SET_MIN, VAR_SET_DIV, VAR_SET_MUL, VARARR_SET, VARARR_SET_PLUS, VARARR_SET_MIN, VARARR_SET_DIV, VARARR_SET_MUL, /* STATEMENTS */ STM_IF, STM_FOR, STM_DO, STM_WHILE, STM_BREAK, STM_CONTINUE, /* FUNCTIONS */ FUNC_CALL, FRESET_TO_DEFAULTS, FINT, FABS, FSIN, FCOS, FTAN, FASIN, FACOS, FATAN, FSQR, FSQRT, FLOG, FLOG10, FSIGN, FPOW, FRANDOM, FMIN, FMAX, FVLENGTH, FVANGLE, FDATA_OSC, FDATA_FREQ, FDEBUG_PRINT, FGBEGIN, FGEND, FGVERTEX, FGCOLOR, /* VARIABLES */ VARRAY, VINTVAR, VINTVAR_LAST = 1023, /* USER VARIABLES */ VUSER, VUSER_LAST = 10240 - 1, } Opcode; typedef struct { char *varname; union { float f; float *p; } num; } VarDescription; typedef struct { char *funcname; int funcopcode; int argcount; } FuncDescription; typedef struct { char *arrname; int arropcode; int dcnt; int *dims; float *data; } ArrayDescription; typedef struct { float starttime; float time; float frame; float width, height; float left, right; float top, bottom; float mousex, mousey; float mousebtn1, mousebtn2, mousebtn3; float i_zoom; /* zoom related to cx:cy. >1 zooms in */ float i_rot; /* rotate related to cx:cy. >0 clockwise */ float i_cx, i_cy; /* 0:0 -- upper left; 1:1 -- bottom right; */ float i_dx, i_dy; /* background texture offset: +:+ to bottom right */ float i_sx, i_sy; /* scale related to cx:cy. >1 zoom bg.texture in */ float i_ox, i_oy; /* 0:0 -- upper left; 1:1 -- bottom right; */ float i_decay; /* >1 -- more decay */ float i_envR, i_envG, i_envB, i_envA; float i_oscR, i_oscG, i_oscB, i_oscA; float i_obR, i_obG, i_obB, i_obA; float i_ibR, i_ibG, i_ibB, i_ibA; float zoom; float rot; float cx, cy; float dx, dy; float sx, sy; float ox, oy; float decay; float envR, envG, envB, envA; float oscR, oscG, oscB, oscA; float obR, obG, obB, obA; float ibR, ibG, ibB, ibA; float osc_look; float osc_look_param1; float osc_look_param2; float osc_additive; float osc_resolution; float osc_type; float osc_angle; float osc_size; float osc_amplitude; float tex_wrap; float tex_invert; float tex_solarize; float opt_wireframe; int opt_active_preset; int opt_reread_presets; float ppix_x; float ppix_y; float ppix_cx; float ppix_cy; float ppix_dx; float ppix_dy; float ppix_sx; float ppix_sy; float ppix_zoom; float ppix_rot; float ppix_rad; float ppix_ang; float i_ob_width, i_ib_width; float ob_width, ib_width; float const_pi; float const_e; float const_sqrt2; float const_begin_points; float const_begin_lines; float const_begin_line_strip; float const_begin_line_loop; float const_begin_triangles; float const_begin_triangle_strip; float const_begin_triangle_fan; float const_begin_quads; float const_begin_quad_strip; float const_begin_polygon; float (*data_osc)[512]; float (*data_freq)[256]; struct { int att_init; int bcnt; float maxf[3]; float att[3]; float attq[3]; float avg_vol; float beat; } freqs; struct { int enabled; int begin; } glstate; int intern_vars_last_ind; int intern_vars_count; VarDescription *intern_vars_desc; int user_vars_last_ind; int user_vars_count; VarDescription *user_vars_desc; int funcs_last_ind; int funcs_count; FuncDescription *funcs; int user_arr_last_ind; int user_arr_count; ArrayDescription *user_arr_desc; int code_perFrame_len; Code *code_perFrame; int code_perPixel_len; Code *code_perPixel; int code_postFrame_len; Code *code_postFrame; } DynamicsData; #define IS_VAR_INTERN(_i) \ (((_i)>=VINTVAR) && ((_i)<=VINTVAR_LAST)) #define IS_VAR_USER(_i)\ (((_i)>=VUSER) && ((_i)<=VUSER_LAST)) #define IS_VAR_INTERN_VALID(_d, _i) \ (((_i)>=VINTVAR) && (((_i) - VINTVAR)<(_d)->intern_vars_last_ind)) #define IS_VAR_USER_VALID(_d, _i)\ (((_i)>=VUSER) && (((_i) - VUSER)<(_d)->user_vars_last_ind)) #define GET_VAR_PTR(_d, _i)\ (IS_VAR_INTERN(_i) ? ((_d)->intern_vars_desc[(_i) - VINTVAR].num.p) : \ (IS_VAR_USER(_i) ? (&((_d)->user_vars_desc[(_i) - VUSER].num.f)) : NULL)) #define GET_VAR_PTR_CHECK(_d, _i)\ (IS_VAR_INTERN_VALID((_d), (_i)) ? ((_d)->intern_vars_desc[(_i) - VINTVAR].num.p) : \ (IS_VAR_USER_VALID((_d), (_i)) ? (&((_d)->user_vars_desc[(_i) - VUSER].num.f)) : NULL)) #define SETUP_ARRAY_FUNC_NAME "setarray" DynamicsData *scivi_dyn_data_init(); void scivi_dyn_data_finit(DynamicsData *d); void scivi_dyn_frame_process(DynamicsData *d); void scivi_dyn_pixel_process(DynamicsData *d, float x, float y, float *nx, float *ny); void scivi_dyn_postframe_process(DynamicsData *d); int scivi_dyn_init_code_from_strings(DynamicsData *d, const char *code_init, const char *code_perframe, const char *code_perpixel, const char *code_postframe); int scivi_dyn_init_code(DynamicsData *d, PresetInfo *p); int scivi_dyn_declare_variable(DynamicsData *d, char *vn); int scivi_dyn_declare_array(DynamicsData *d, char *aname, int *dims, int dcnt); #endif /* ! DYNAM_H */