diff --git a/src/Makefile.am b/src/Makefile.am index 59a9e2b..bcc4a96 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,6 @@ libinfinite_la_SOURCES = \ renderer.cc renderer.h\ compute.c compute.h \ display.c display.h \ - prefs.c prefs.h\ effects.c effects.h\ cputest.c cputest.h\ mmx.h types.h diff --git a/src/compute.c b/src/compute.c index 64a1779..1598b65 100644 --- a/src/compute.c +++ b/src/compute.c @@ -16,9 +16,9 @@ #include #include -#include "config.h" #include "compute.h" -#include "prefs.h" +#include "config.h" +#include "types.h" #ifdef MMX_DETECTION #include "mmx.h" #endif @@ -184,14 +184,11 @@ static inline void compute_generate_sector(guint32 g, guint32 f, guint32 p1, gui } } -/* - * Public functions - */ -void compute_init(void) +void compute_init(gint32 width, gint32 height, gint32 scale) { - scr_par.width = config_get_xres(); - scr_par.height = config_get_yres(); - scr_par.scale = config_get_sres(); + scr_par.width = width; + scr_par.height = height; + scr_par.scale = scale; 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)); diff --git a/src/compute.h b/src/compute.h index 5f7be4d..35298df 100644 --- a/src/compute.h +++ b/src/compute.h @@ -60,15 +60,7 @@ void compute_vector_field_destroy(vector_field_t *vector_field); */ void compute_quit(void); -/* - * Initialize this module. - * - * For to do this the user configuration options are readed and - * internals structures setting accordingly. If this options - * change, the module must be reinitialized in order to the - * changes take effect. - */ -void compute_init(void); +void compute_init(gint32 width, gint32 height, gint32 scale); /* * Tell the module that the screen has been resized. diff --git a/src/display.c b/src/display.c index 8db2c9f..b95327d 100644 --- a/src/display.c +++ b/src/display.c @@ -20,7 +20,7 @@ #include "config.h" #include "display.h" -#include "prefs.h" +#include "types.h" #define wrap(a) (a < 0 ? 0 : (a > 255 ? 255 : a)) #define assign_max(p, a) (*p <= a ? *p = a : 0) @@ -208,18 +208,18 @@ static void line(gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c) } } -void display_init(void) +void display_init(gint32 width, gint32 height, gint32 scale) { - scr_par.width = config_get_xres(); - scr_par.height = config_get_yres(); - scr_par.scale = config_get_sres(); + scr_par.width = width; + scr_par.height = height; + scr_par.scale = scale; pcm_data_mutex = SDL_CreateMutex(); - compute_init(); - init_sdl(scr_par.width, scr_par.height, scr_par.scale); + compute_init(width, height, scale); + init_sdl(width, height, scale); generate_colors(); effects_load_effects(); - vector_field = compute_vector_field_new(scr_par.width, scr_par.height); + vector_field = compute_vector_field_new(width, height); compute_generate_vector_field(vector_field); } diff --git a/src/display.h b/src/display.h index 9c29e83..f32a80f 100644 --- a/src/display.h +++ b/src/display.h @@ -27,15 +27,13 @@ /* * Initializes the display related structures. * - * This function reads the user configuration options - * and set his internal data structures accordingly. - * It also initializes the SDL library. + * It initializes the module and the SDL library. * * Warning: because this function initializes the SDL * 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(gint32 width, gint32 height, gint32 scale); /* * Closes the display module. @@ -55,10 +53,6 @@ void display_quit(void); /* * Change the size of the display to the new dimension * width x height. - * - * It is supposed that this must be called when the display - * screen is resized (i.e. when is resized the window where - * the screen is embedded in). */ void display_resize(gint32 width, gint32 height); diff --git a/src/main.cc b/src/main.cc index bb8d7a7..0819029 100644 --- a/src/main.cc +++ b/src/main.cc @@ -21,8 +21,8 @@ extern "C" { #include "config.h" -#include "prefs.h" #include "renderer.h" +#include "types.h" } static const char about_text[] = @@ -69,7 +69,6 @@ public: private: void load_settings (); - void save_settings(); }; EXPORT InfinityPlugin aud_plugin_instance; @@ -102,7 +101,6 @@ void InfinityPlugin::clear () void InfinityPlugin::cleanup(void) { g_message("Infinity: cleanup()"); - save_settings(); renderer_finish(); } @@ -123,20 +121,4 @@ static const char * const defaults[] = { void InfinityPlugin::load_settings(void) { aud_config_set_defaults (CFGID, defaults); - - config_set_x(20); - config_set_y(10); - config_set_xres(aud_get_int(CFGID, "width")); - config_set_yres(aud_get_int(CFGID, "height")); - config_set_teff(aud_get_int(CFGID, "effect_time")); - config_set_tcol(aud_get_int(CFGID, "palette_time")); - config_set_sres(aud_get_int(CFGID, "scale_factor")); - config_set_fps(aud_get_int(CFGID, "max_fps")); - config_set_show_title(aud_get_bool(CFGID, "show_title")); -} - -void InfinityPlugin::save_settings(void) -{ - aud_set_int(CFGID, "width", config_get_xres()); - aud_set_int(CFGID, "height", config_get_yres()); } diff --git a/src/prefs.c b/src/prefs.c deleted file mode 100644 index 7965181..0000000 --- a/src/prefs.c +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include - -#include "config.h" -#include "prefs.h" - -typedef struct t_config { - gint32 x, y; - gint32 xres; - gint32 yres; - gint32 sres; - gint32 teff; - gint32 tcol; - gint32 fps; - gboolean show_title; -} t_config; - -static t_config config; - -void config_save_prefs(void) -{ - // TODO until it gets repaired, plugin forgets its window size when quit - g_message("TODO config_save_prefs()"); -} - -gboolean config_is_initialized(void) -{ - return (config.xres != 0) && (config.yres != 0) && - (config.sres != 0) && (config.teff != 0) && - (config.tcol != 0) && (config.fps != 0); -} - -void config_set_x(gint32 value) -{ - config.x = value; -} - -void config_set_y(gint32 value) -{ - config.y = value; -} - -void config_set_xres(gint32 value) -{ - config.xres = value; -} - -void config_set_yres(gint32 value) -{ - config.yres = value; -} - -void config_set_teff(gint32 value) -{ - config.teff = value; -} - -void config_set_tcol(gint32 value) -{ - config.tcol = value; -} - -void config_set_sres(gint32 value) -{ - config.sres = value; -} - -void config_set_fps(gint32 value) -{ - config.fps = value; -} - -void config_set_show_title(gboolean value) -{ - config.show_title = value; -} - -gint32 config_get_x(void) -{ - return config.x; -} - -gint32 config_get_y(void) -{ - return config.y; -} - -gint32 config_get_xres(void) -{ - return config.xres; -} - -gint32 config_get_yres(void) -{ - return config.yres; -} - -gint32 config_get_teff(void) -{ - return config.teff; -} - -gint32 config_get_tcol(void) -{ - return config.tcol; -} - -gint32 config_get_sres(void) -{ - return config.sres; -} - -gint32 config_get_fps(void) -{ - return config.fps; -} - -gboolean config_get_show_title(void) -{ - return config.show_title; -} diff --git a/src/prefs.h b/src/prefs.h deleted file mode 100644 index 474e301..0000000 --- a/src/prefs.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ -#ifndef __INFINITY_CONFIG__ -#define __INFINITY_CONFIG__ - - -#include - -#define CFGID "infinity" - -/* - * This structure is intended to be used for every module - * that want to get your own copy of the screen parameters, - * it is not used by the config module itself. - * Is responsibility of the modules that create his own - * copy of the screen parameters to keep consistent that - * parameters with each other copy, it is not responsibility - * of the config module. - */ -typedef struct _t_screen_parameters { - gint32 x, y; - gint32 width; - gint32 height; - gint32 scale; - gint32 bpp; /* bytes per pixels. */ -} t_screen_parameters; - - -void config_save_prefs(void); - -/* - * Return TRUE if config_plugin_load_prefs() or - * config_set_default_values() has been called. - */ -gboolean config_is_initialized(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); - -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/renderer.cc b/src/renderer.cc index cb16e71..0fd62ec 100644 --- a/src/renderer.cc +++ b/src/renderer.cc @@ -30,10 +30,10 @@ extern "C" { #include "config.h" -#include "renderer.h" -#include "prefs.h" -#include "effects.h" #include "display.h" +#include "effects.h" +#include "renderer.h" +#include "types.h" #if MMX_DETECTION #include "cputest.h" @@ -90,9 +90,9 @@ void renderer_init(void) } } initializing = TRUE; - scr_par.width = config_get_xres(); - scr_par.height = config_get_yres(); - scr_par.scale = config_get_sres(); + scr_par.width = aud_get_int(CFGID, "width"); + scr_par.height = aud_get_int(CFGID, "height"); + scr_par.scale = aud_get_int(CFGID, "scale_factor"); old_color = 0; color = 0; @@ -106,7 +106,7 @@ void renderer_init(void) quiting = FALSE; first_xevent = TRUE; - display_init(); + display_init(scr_par.width, scr_par.height, scr_par.scale); current_title = g_strdup("Infinity"); set_title(); title_timer = g_timer_new(); @@ -237,7 +237,7 @@ static void check_events() * XWindowAttributes attr; * XSetWindowAttributes s_attr;*/ - if (config_get_show_title()) { + if (aud_get_int(CFGID, "show_title")) { if (g_timer_elapsed(title_timer, NULL) > 1.0) { if (aud_drct_get_playing() && aud_drct_get_ready()) { if (current_title) @@ -429,8 +429,8 @@ static int renderer(void *arg) break; if (must_resize) { display_resize(scr_par.width, scr_par.height); - config_set_xres(scr_par.width); - config_set_yres(scr_par.height); + aud_set_int(CFGID, "width", scr_par.width); + aud_set_int(CFGID, "heigth", scr_par.height); must_resize = FALSE; g_return_val_if_fail(SDL_LockMutex(resizing_mutex) >= 0, -1); resizing = FALSE; @@ -516,8 +516,8 @@ static int renderer_mmx(void *arg) break; if (must_resize) { display_resize(scr_par.width, scr_par.height); - config_set_xres(scr_par.width); - config_set_yres(scr_par.height); + aud_set_int(CFGID, "width", scr_par.width); + aud_set_int(CFGID, "heigth", scr_par.height); must_resize = FALSE; g_return_val_if_fail(SDL_LockMutex(resizing_mutex) >= 0, -1); resizing = FALSE; diff --git a/src/types.h b/src/types.h index 59a0403..86e7efa 100644 --- a/src/types.h +++ b/src/types.h @@ -18,11 +18,17 @@ #include +#define CFGID "infinity" + +// existence of this header smells as bad design... +typedef struct _t_screen_parameters { + gint32 x, y; + gint32 width; + gint32 height; + gint32 scale; + gint32 bpp; /* bytes per pixels. */ +} t_screen_parameters; -/* - * Represents a single byte type. - */ typedef Uint8 byte; - #endif /* __INFINITY_TYPES__ */