From 82e469a11e060f24f17dfcef8c35fb464170182c Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Thu, 16 Sep 2010 19:28:59 +0000 Subject: [PATCH] Now save all color ranges, not only the cycling ones. Only solid ranges (1 color) are discarded. Also fixed a few harmless compilation warnings git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1619 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/engine.c | 6 +++--- src/engine.h | 6 +++--- src/fileformats.c | 20 ++++++++++++++------ src/loadsave.c | 2 +- src/pages.c | 2 +- src/pages.h | 6 ++++++ 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/engine.c b/src/engine.c index 9d269bfa..22185cf0 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1698,7 +1698,7 @@ void Close_window(void) //---------------- Dessiner un bouton normal dans une fenêtre ---------------- void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height, - char * title,byte undersc_letter,byte clickable) + const char * title,byte undersc_letter,byte clickable) { byte title_color; word text_x_pos,text_y_pos; @@ -1953,7 +1953,7 @@ void Window_clear_input_button(T_Special_button * button) T_Normal_button * Window_set_normal_button(word x_pos, word y_pos, word width, word height, - char * title, byte undersc_letter, + const char * title, byte undersc_letter, byte clickable, word shortcut) { T_Normal_button * temp=NULL; @@ -1983,7 +1983,7 @@ T_Normal_button * Window_set_normal_button(word x_pos, word y_pos, T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos, word width, word height, - char * title, byte undersc_letter, + const char * title, byte undersc_letter, byte clickable, word shortcut) { T_Normal_button * temp=NULL; diff --git a/src/engine.h b/src/engine.h index 03755e7d..d9f16861 100644 --- a/src/engine.h +++ b/src/engine.h @@ -40,7 +40,7 @@ void Open_popup (word x_pos, word y_pos, word width, word height); void Close_popup (void); void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height, - char * title,byte undersc_letter,byte clickable); + const char * title,byte undersc_letter,byte clickable); void Window_select_normal_button(word x_pos,word y_pos,word width,word height); void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height); void Window_draw_palette_bouton(word x_pos,word y_pos); @@ -54,11 +54,11 @@ void Window_clear_input_button(T_Special_button * button); void Window_draw_input_bouton(word x_pos, word y_pos, word width_in_characters); T_Normal_button * Window_set_normal_button(word x_pos, word y_pos, - word width, word height, char * title, byte undersc_letter, + word width, word height, const char * title, byte undersc_letter, byte clickable, word shortcut); T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos, - word width, word height, char * title, byte undersc_letter, + word width, word height, const char * title, byte undersc_letter, byte clickable, word shortcut); T_Palette_button * Window_set_palette_button(word x_pos, word y_pos); diff --git a/src/fileformats.c b/src/fileformats.c index 74442be3..4aef1ab4 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -660,7 +660,7 @@ void Load_LBM(T_IO_Context * context) && (Read_byte(LBM_file,&min_col)) && (Read_byte(LBM_file,&max_col))) { - if (section_size == 8 && (flags & 1) && min_col != max_col) + if (section_size == 8 && min_col != max_col) { // Valid cycling range if (max_colCycle_range[context->Color_cycles].Start=min_col; context->Cycle_range[context->Color_cycles].End=max_col; context->Cycle_range[context->Color_cycles].Inverse=(flags&2)?1:0; - context->Cycle_range[context->Color_cycles].Speed=rate/78; + context->Cycle_range[context->Color_cycles].Speed=(flags&1) ? rate/78 : 0; context->Color_cycles++; } @@ -1015,11 +1015,15 @@ void Save_LBM(T_IO_Context * context) for (i=0; iColor_cycles; i++) { + word flags=0; + flags|= context->Cycle_range[i].Speed?1:0; // Cycling or not + flags|= context->Cycle_range[i].Inverse?2:0; // Inverted + Write_bytes(LBM_file,"CRNG",4); Write_dword_be(LBM_file,8); // Section size Write_word_be(LBM_file,0); // Padding Write_word_be(LBM_file,context->Cycle_range[i].Speed*78); // Rate - Write_word_be(LBM_file,1|(context->Cycle_range[i].Inverse?2:0)); // Flags + Write_word_be(LBM_file,flags); // Flags Write_byte(LBM_file,context->Cycle_range[i].Start); // Min color Write_byte(LBM_file,context->Cycle_range[i].End); // Max color // No padding, size is multiple of 2 @@ -2027,7 +2031,7 @@ void Load_GIF(T_IO_Context * context) && (Read_byte(GIF_file,&min_col)) && (Read_byte(GIF_file,&max_col))) { - if ((flags & 1) && min_col != max_col) + if (min_col != max_col) { // Valid cycling range if (max_colCycle_range[context->Color_cycles].Start=min_col; context->Cycle_range[context->Color_cycles].End=max_col; context->Cycle_range[context->Color_cycles].Inverse=(flags&2)?1:0; - context->Cycle_range[context->Color_cycles].Speed=rate/78; + context->Cycle_range[context->Color_cycles].Speed=(flags&1)?rate/78:0; context->Color_cycles++; } @@ -2414,8 +2418,12 @@ void Save_GIF(T_IO_Context * context) Write_byte(GIF_file,context->Color_cycles*6); for (i=0; iColor_cycles; i++) { + word flags=0; + flags|= context->Cycle_range[i].Speed?1:0; // Cycling or not + flags|= context->Cycle_range[i].Inverse?2:0; // Inverted + Write_word_be(GIF_file,context->Cycle_range[i].Speed*78); // Rate - Write_word_be(GIF_file,1|(context->Cycle_range[i].Inverse?2:0)); // Flags + Write_word_be(GIF_file,flags); // Flags Write_byte(GIF_file,context->Cycle_range[i].Start); // Min color Write_byte(GIF_file,context->Cycle_range[i].End); // Max color } diff --git a/src/loadsave.c b/src/loadsave.c index 5a7ce0f3..43346b8a 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -1158,7 +1158,7 @@ void Init_context_layered_image(T_IO_Context * context, char *file_name, char *f // Color cyling ranges: for (i=0; i<16; i++) { - if (Main_backups->Pages->Gradients->Range[i].Start!=Main_backups->Pages->Gradients->Range[i].End && Main_backups->Pages->Gradients->Range[i].Speed) + if (Main_backups->Pages->Gradients->Range[i].Start!=Main_backups->Pages->Gradients->Range[i].End) { context->Cycle_range[context->Color_cycles].Start=Main_backups->Pages->Gradients->Range[i].Start; context->Cycle_range[context->Color_cycles].End=Main_backups->Pages->Gradients->Range[i].End; diff --git a/src/pages.c b/src/pages.c index cde2b86a..066eaa92 100644 --- a/src/pages.c +++ b/src/pages.c @@ -901,7 +901,7 @@ int Backup_with_new_dimensions(int width,int height) } /// -/// Resizes a backup step in-place. +/// Resizes a backup step in-place (doesn't add a Undo/Redo step). /// Should only be called after an actual backup, because it loses the current. /// pixels. This function is meant to be used from within Lua scripts. int Backup_in_place(int width,int height) diff --git a/src/pages.h b/src/pages.h index a6309c53..5c5ba48c 100644 --- a/src/pages.h +++ b/src/pages.h @@ -93,7 +93,13 @@ void Free_page_of_a_list(T_List_of_pages * list); int Init_all_backup_lists(int width,int height); void Set_number_of_backups(int nb_backups); +int Backup_new_image(byte layers,int width,int height); int Backup_with_new_dimensions(int width,int height); +/// +/// Resizes a backup step in-place (doesn't add a Undo/Redo step). +/// Should only be called after an actual backup, because it loses the current. +/// pixels. This function is meant to be used from within Lua scripts. +int Backup_in_place(int width,int height); /// Backup the spare image, the one you don't see. void Backup_the_spare(dword layer_mask); int Backup_and_resize_the_spare(int width,int height);