From 6189b4391777a01fc1db1e53764cdbb08ab3b667 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 15 Nov 2018 23:39:00 +0100 Subject: [PATCH] Add a gfx2.ini parameter to set the gamma for Thomson MO/TO palettes --- share/grafx2/gfx2def.ini | 5 +++++ src/buttons.c | 2 +- src/readini.c | 7 +++++++ src/saveini.c | 4 ++++ src/struct.h | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/share/grafx2/gfx2def.ini b/share/grafx2/gfx2def.ini index 2c1d3b37..54531c2d 100644 --- a/share/grafx2/gfx2def.ini +++ b/share/grafx2/gfx2def.ini @@ -416,5 +416,10 @@ ; is animation frames. ; Default_mode_layers = no; (Default no) + + ; Set the gamma value used to translate palettes from Thomson MO/TO + ; pictures. 10 is 1.0, 22 is 2.2 etc. + ; + MOTO_gamma = 28; (Default 28) ; end of configuration diff --git a/src/buttons.c b/src/buttons.c index 18d84ef5..1edceeb9 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1011,7 +1011,7 @@ void Button_Settings(int btn) {" --- Format options ---",0,NULL,0,0,0,NULL}, {"Screen size in GIF:",1,&(selected_config.Screen_size_in_GIF),0,1,0,Lookup_YesNo}, {"Clear palette:",1,&(selected_config.Clear_palette),0,1,0,Lookup_YesNo}, - {"",0,NULL,0,0,0,NULL}, + {"MO6/TO8 palette gamma",1,&(selected_config.MOTO_gamma),10,30,2,NULL}, {"",0,NULL,0,0,0,NULL}, {"",0,NULL,0,0,0,NULL}, {"",0,NULL,0,0,0,NULL}, diff --git a/src/readini.c b/src/readini.c index edf4e9fe..810a73b2 100644 --- a/src/readini.c +++ b/src/readini.c @@ -1048,6 +1048,13 @@ int Load_INI(T_Config * conf) { conf->Default_mode_layers=(values[0]!=0); } + + conf->MOTO_gamma=28; + // Optional, gamma value used for palette of load/save Thomson MO/TO pictures (>=2.6) + if (!Load_INI_get_values (file,buffer,"MOTO_gamma",1,values)) + { + conf->MOTO_gamma=(byte)values[0]; + } // Insert new values here diff --git a/src/saveini.c b/src/saveini.c index ad7b8c43..419b4e18 100644 --- a/src/saveini.c +++ b/src/saveini.c @@ -754,6 +754,10 @@ int Save_INI(const T_Config * conf) if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Default_mode_layers",1,values,1))) goto Erreur_Retour; + values[0]=conf->MOTO_gamma; + if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"MOTO_gamma",1,values,0))) + goto Erreur_Retour; + // Insert new values here Save_INI_flush(old_file,new_file,buffer); diff --git a/src/struct.h b/src/struct.h index 9f461d47..6efc2e88 100644 --- a/src/struct.h +++ b/src/struct.h @@ -379,6 +379,7 @@ typedef struct byte Tilemap_show_count; ///< Boolean, true if the Tilemap tool should display tile count after analysis. byte Use_virtual_keyboard; ///< 0: Auto, 1: On, 2: Off byte Default_mode_layers; ///< Indicates if default new image has layers (alternative is animation) + byte MOTO_gamma; ///< Number, 10 x the Gamma used for converting MO6/TO8/TO9 palette } T_Config;