From 5a6333e5e8f4b1209fb0112e06cd04d070b181f7 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 15 Dec 2018 20:19:29 +0100 Subject: [PATCH] define COLOR_CYCLING_SPEED_MAX --- src/fileformats.c | 15 +++++++++++---- src/helpfile.h | 8 +++++--- src/loadsave.h | 2 +- src/miscfileformats.c | 14 +++++++------- src/struct.h | 4 +++- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/fileformats.c b/src/fileformats.c index 252b3a4a..981837fa 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -1596,11 +1596,13 @@ void Load_IFF(T_IO_Context * context) } else { + word speed; + context->Cycle_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=(flags&1) ? rate/78 : 0; - + speed = (flags&1) ? rate/78 : 0; + context->Cycle_range[context->Color_cycles].Speed = (speed > COLOR_CYCLING_SPEED_MAX) ? COLOR_CYCLING_SPEED_MAX : speed; context->Color_cycles++; } } @@ -1680,8 +1682,10 @@ void Load_IFF(T_IO_Context * context) context->Cycle_range[context->Color_cycles].End = end; if (direction != 0) { + dword speed; context->Cycle_range[context->Color_cycles].Inverse = (~direction >> 15) & 1; - context->Cycle_range[context->Color_cycles].Speed = 3501400 / (seconds * 1000000 + microseconds); + speed = 3501400 / (seconds * 1000000 + microseconds); + context->Cycle_range[context->Color_cycles].Speed = (speed > COLOR_CYCLING_SPEED_MAX) ? COLOR_CYCLING_SPEED_MAX : speed; } else { @@ -4503,7 +4507,10 @@ void Load_GIF(T_IO_Context * context) && Read_byte(GIF_file,&(IDB.Indicator)) && IDB.Image_width && IDB.Image_height) { - + GFX2_Log(GFX2_DEBUG, "GIF Image descriptor %u Pos (%u,%u) %ux%u %s%slocal palette %ubpp\n", + number_LID, IDB.Pos_X, IDB.Pos_Y, IDB.Image_width, IDB.Image_height, + (IDB.Indicator & 0x40) ? "interlaced " : "", (IDB.Indicator & 0x80) ? "" : "no ", + (IDB.Indicator & 7) + 1); // Palette locale dispo = (IDB.Indicator and $80) // Image entrelacée = (IDB.Indicator and $40) // Ordre de classement = (IDB.Indicator and $20) diff --git a/src/helpfile.h b/src/helpfile.h index 7895ce1d..4cb9004d 100644 --- a/src/helpfile.h +++ b/src/helpfile.h @@ -1200,9 +1200,11 @@ static const T_Help_table helptable_grad_rect[] = HELP_TEXT ("") HELP_TEXT ("These options allow you to use animation of") HELP_TEXT ("colors: Grafx2 will shift palette entries") - HELP_TEXT ("at real-time. Note that only the IFF file") - HELP_TEXT ("format can record these settings, and very") - HELP_TEXT ("few image viewers will play it back.") + HELP_TEXT ("at real-time. We save theses data in IFF,") + HELP_TEXT ("NEO and Degas Elite formats. Also in non") + HELP_TEXT ("standard extension of PNG and GIF files.") + HELP_TEXT ("But very few image viewers will play them") + HELP_TEXT ("back.") HELP_TEXT ("") HELP_TEXT ("- Cycling: Activates or desactivates the") HELP_TEXT ("cycling of colors when you're in the editor.") diff --git a/src/loadsave.h b/src/loadsave.h index 0f64589f..91414bb6 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -48,7 +48,7 @@ typedef struct byte Start; ///< First color byte End; ///< Last color byte Inverse; ///< Boolean, true if the gradient goes in descending order - byte Speed; ///< Frequency of cycling, from 1 (slow) to 64 (fast) + byte Speed; ///< Frequency of cycling, from 1 (slow) to COLOR_CYCLING_SPEED_MAX (fast) } T_Color_cycle; typedef struct diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 91853327..7f84abbf 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -1578,12 +1578,12 @@ static void PI1_load_ranges(T_IO_Context * context, const byte * buffer, int siz // Sanity checks if (min_col < 256 && max_col < 256 && direction < 3 && (direction == 1 || delay < 128)) { - int speed = 105; + int speed = 1; if (delay < 128) speed = 210/(128-delay); - // Grafx2's slider has a limit of 105 - if (speed>105) - speed = 105; + // Grafx2's slider has a limit of COLOR_CYCLING_SPEED_MAX + if (speed > COLOR_CYCLING_SPEED_MAX) + speed = COLOR_CYCLING_SPEED_MAX; context->Cycle_range[context->Color_cycles].Start=min_col; context->Cycle_range[context->Color_cycles].End=max_col; context->Cycle_range[context->Color_cycles].Inverse= (direction==0); @@ -2359,9 +2359,9 @@ void Load_NEO(T_IO_Context * context) if (color_cycling_delay != 0) context->Cycle_range[context->Color_cycles].Speed = 175 / color_cycling_delay; else - context->Cycle_range[context->Color_cycles].Speed = 64; // fastest - if (context->Cycle_range[context->Color_cycles].Speed > 64) - context->Cycle_range[context->Color_cycles].Speed = 64; + context->Cycle_range[context->Color_cycles].Speed = COLOR_CYCLING_SPEED_MAX; // fastest + if (context->Cycle_range[context->Color_cycles].Speed > COLOR_CYCLING_SPEED_MAX) + context->Cycle_range[context->Color_cycles].Speed = COLOR_CYCLING_SPEED_MAX; } else context->Cycle_range[context->Color_cycles].Speed = 0; // cycling off diff --git a/src/struct.h b/src/struct.h index 844fbddb..19aa5d3e 100644 --- a/src/struct.h +++ b/src/struct.h @@ -268,9 +268,11 @@ typedef struct dword Inverse; ///< Boolean, true if the gradient goes in descending order dword Mix; ///< Amount of randomness to add to the mix (0-255) dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering) - byte Speed; ///< Speed of cycling. 0 for disabled, 1-64 otherwise. 1=>0.2856Hz, 64=>18.28Hz + byte Speed; ///< Speed of cycling. 0 for disabled, max value COLOR_CYCLING_SPEED_MAX. 1=>0.2856Hz, 64=>18.28Hz } T_Gradient_range; +#define COLOR_CYCLING_SPEED_MAX 250 + /// Data for a full set of gradients. typedef struct {